Skip to content

Commit

Permalink
Merge pull request #1441 from davemfish/bugfix/CV-992-nodata-casting
Browse files Browse the repository at this point in the history
CV: bugfix for passing numpy float type to gdal
  • Loading branch information
phargogh authored Nov 6, 2023
2 parents 2cafe8b + 5c86d3c commit 2a02f75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 7 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ Unreleased Changes
* Version metadata at import time is now fetched with
``importlib.metadata`` instead of ``pkg_resources``.
(`#1442 <https://github.com/natcap/invest/issues/1442>`_)
* Pollination
* Replaced custom kernel implementation with ``pygeoprocessing.kernels``.
Convolution results may be slightly different (more accurate).
* Coastal Vulnerability
* Fixed a bug where the model would crash when processing a float type
bathymetry raster with no nodata value.
https://github.com/natcap/invest/issues/992
* NDR
* Fixing an issue where minor geometric issues in the watersheds input
(such as a ring self-intersection) would raise an error in the model.
Expand All @@ -71,6 +72,9 @@ Unreleased Changes
* Fixed an issue in NDR's effective retention where, on rasters with more
than 2^31 pixels, the model would crash with an error relating to a
negative (overflowed) index. https://github.com/natcap/invest/issues/1431
* Pollination
* Replaced custom kernel implementation with ``pygeoprocessing.kernels``.
Convolution results may be slightly different (more accurate).
* SDR
* RKLS, USLE, avoided erosion, and avoided export rasters will now have
nodata in streams (`#1415 <https://github.com/natcap/invest/issues/1415>`_)
Expand Down
9 changes: 1 addition & 8 deletions src/natcap/invest/coastal_vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,14 +2194,7 @@ def warp_and_mask_bathymetry(
bathymetry_raster_path)
bathy_nodata = bathy_info['nodata'][0]
if bathy_nodata is None:
# If a nodata value is not provided, assume the largest positive value
# that the datatype can support. Once we finish masking bathymetry,
# all positive values are masked out anyways so this should be safe.
try:
bathy_nodata = numpy.finfo(bathy_info['numpy_type']).max
except ValueError:
# When the numpy dtype is not a float, must be an int.
bathy_nodata = numpy.iinfo(bathy_info['numpy_type']).max
bathy_nodata = pygeoprocessing.choose_nodata(bathy_info['numpy_type'])
bathy_target_dtype = bathy_info['datatype']

clip_and_project_raster(
Expand Down

0 comments on commit 2a02f75

Please sign in to comment.