From 6c0d5553ce725ad2f3cf5fc93572568869223eab Mon Sep 17 00:00:00 2001 From: davemfish Date: Thu, 2 Nov 2023 09:55:37 -0400 Subject: [PATCH 1/3] use pygeoprocessing to correctly choose nodata values to pass to gdal. #992 --- src/natcap/invest/coastal_vulnerability.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/natcap/invest/coastal_vulnerability.py b/src/natcap/invest/coastal_vulnerability.py index dcfcfab1c4..630e8987af 100644 --- a/src/natcap/invest/coastal_vulnerability.py +++ b/src/natcap/invest/coastal_vulnerability.py @@ -2191,14 +2191,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( From 737e95aee866c94d020dd359d07e25fb7dfa04ea Mon Sep 17 00:00:00 2001 From: davemfish Date: Thu, 2 Nov 2023 10:04:19 -0400 Subject: [PATCH 2/3] note for HISTORY. #992 --- HISTORY.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 522ab8477a..ff404dc6ba 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -49,6 +49,10 @@ Unreleased Changes (`#1374 `_) * Datastack archives will now be correctly extracted (`#1308 `_) +* 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. From 1a16f6abe7dea6068ab8252b0778dc07d6c97878 Mon Sep 17 00:00:00 2001 From: davemfish Date: Thu, 2 Nov 2023 11:13:40 -0400 Subject: [PATCH 3/3] unpin pygeoprocessing. #992 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d9dc564d7e..31e022aa3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ numpy>=1.11.0,!=1.16.0 Rtree>=0.8.2,!=0.9.1 shapely>=2.0.0 scipy>=1.9.0 -pygeoprocessing==2.4.0 +pygeoprocessing taskgraph>=0.11.0 psutil>=5.6.6 chardet>=3.0.4