From f0a4b224d8cbd86adfab25bd072958f361e930cb Mon Sep 17 00:00:00 2001 From: Rich Sharp Date: Tue, 15 Jun 2021 10:57:15 -0700 Subject: [PATCH 1/3] re #203 noting new release --- HISTORY.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 1db1832c..6d103734 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,7 +1,7 @@ Release History =============== -Unreleased Changes +2.2.1 (2021-06-15) ------------------ * Added a ``single_outlet_tuple`` parameter to ``routing.fill_pits`` that forces a DEM to only have one outlet at any point on the raster. The @@ -23,7 +23,7 @@ Unreleased Changes bounding box cannot be transformed to provide more helpful details. * Add support and testing for GDAL 3.3.0. -2.2.0 (2020-05-14) +2.2.0 (2021-05-14) ------------------ * Adding explicit support for Python 3.9 and testing on Python 3.9. * Fixed an issue in ``create_raster_from_vector_extents`` that would cause a From 65cf904108c1de758f167bfb5c726167793aa56c Mon Sep 17 00:00:00 2001 From: Rich Sharp Date: Mon, 21 Jun 2021 08:49:11 -0700 Subject: [PATCH 2/3] i think this is really a minor version bump re #203 --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6d103734..241318ed 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,7 +1,7 @@ Release History =============== -2.2.1 (2021-06-15) +2.3.0 (2021-06-21) ------------------ * Added a ``single_outlet_tuple`` parameter to ``routing.fill_pits`` that forces a DEM to only have one outlet at any point on the raster. The From 9331a1c9a557121898455da962ca41facc272c9a Mon Sep 17 00:00:00 2001 From: Rich Sharp Date: Fri, 2 Jul 2021 15:28:09 -0700 Subject: [PATCH 3/3] fixes #205 ensuring on raster size and generalization for the x/y axis --- HISTORY.rst | 2 ++ src/pygeoprocessing/geoprocessing.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 241318ed..a99b9684 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -22,6 +22,8 @@ Release History * Expanded the error message raised by ``transform_bounding_box`` when the bounding box cannot be transformed to provide more helpful details. * Add support and testing for GDAL 3.3.0. +* Fixed exception occuring in ``stitch_rasters`` when base rasters were + larger than the target raster on the ``y`` axis. 2.2.0 (2021-05-14) ------------------ diff --git a/src/pygeoprocessing/geoprocessing.py b/src/pygeoprocessing/geoprocessing.py index bbc1e84e..29231760 100644 --- a/src/pygeoprocessing/geoprocessing.py +++ b/src/pygeoprocessing/geoprocessing.py @@ -3863,13 +3863,15 @@ def _mult_op(base_array, base_nodata, scale, datatype): _offset_vars = {} overlap = True for (target_to_base_off, off_val, - target_off_id, off_clip_id, win_size_id) in [ + target_off_id, off_clip_id, win_size_id, raster_size) in [ (target_to_base_xoff, offset_dict['xoff'], - 'target_xoff', 'xoff_clip', 'win_xsize'), + 'target_xoff', 'xoff_clip', 'win_xsize', + target_raster_x_size), (target_to_base_yoff, offset_dict['yoff'], - 'target_yoff', 'yoff_clip', 'win_ysize')]: + 'target_yoff', 'yoff_clip', 'win_ysize', + target_raster_y_size)]: _offset_vars[target_off_id] = (target_to_base_off+off_val) - if _offset_vars[target_off_id] > target_raster_x_size: + if _offset_vars[target_off_id] >= raster_size: overlap = False break # how far to move right to get in the target raster @@ -3877,18 +3879,18 @@ def _mult_op(base_array, base_nodata, scale, datatype): if _offset_vars[target_off_id] < 0: _offset_vars[off_clip_id] = -_offset_vars[target_off_id] _offset_vars[win_size_id] = offset_dict[win_size_id] - if _offset_vars[off_clip_id] > _offset_vars[win_size_id]: + if _offset_vars[off_clip_id] >= _offset_vars[win_size_id]: # its too far left for the whole window overlap = False break # make the _offset_vars[win_size_id] smaller if it shifts # off the target window if (_offset_vars[off_clip_id] + _offset_vars[target_off_id] + - _offset_vars[win_size_id] > target_raster_x_size): + _offset_vars[win_size_id] >= raster_size): _offset_vars[win_size_id] -= ( _offset_vars[off_clip_id] + _offset_vars[target_off_id] + - _offset_vars[win_size_id] - target_raster_x_size) + _offset_vars[win_size_id] - raster_size) if not overlap: continue @@ -3899,7 +3901,6 @@ def _mult_op(base_array, base_nodata, scale, datatype): win_xsize=_offset_vars['win_xsize'], win_ysize=_offset_vars['win_ysize']) target_nodata_mask = numpy.isclose(target_array, target_nodata) - base_array = base_band.ReadAsArray( xoff=offset_dict['xoff']+_offset_vars['xoff_clip'], yoff=offset_dict['yoff']+_offset_vars['yoff_clip'],