Urban flood risk mitigation, soil group raster error?

Hello, I am trying to run the urban flood risk mitigation model for the study area of Johannesburg, South Africa. The software allows me to run the model using my data inputs, however I keep receiving errors, which I will paste below. I have tried several times to change the soil group raster, but I always run into the same error, despite the fact that my raster appears to only contain values within the permitted range (1,2,3,4). If anyone could help me with this I would be greatly appreciative.
02/10/2023 11:35:45 natcap.invest.utils Level 100 Writing log messages to [/Users/josephfreimond/Desktop/INVEST OUTPUTS/InVEST-natcap.invest.urban_flood_risk_mitigation-log-2023-02-10–11_35_45.txt]
02/10/2023 11:35:45 main Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.urban_flood_risk_mitigation 3.12.1:
aoi_watersheds_path /Volumes/JOE USB/inVest runoff Inputs/JHB_Watersheds_Study Area.shp
built_infrastructure_vector_path
curve_number_table_path /Users/josephfreimond/Desktop/DEA_Biophysical_Table_INvest_Test.csv
infrastructure_damage_loss_table_path
lulc_path /Volumes/JOE USB/inVest runoff Inputs/dea_land_use_raster.tif
n_workers -1
rainfall_depth 12
results_suffix
soils_hydrological_group_raster_path /Volumes/JOE USB/inVest runoff Inputs/scs_soil_class_test.tif
workspace_dir /Users/josephfreimond/Desktop/INVEST OUTPUTS

02/10/2023 11:35:45 natcap.invest.validation INFO Starting whole-model validation with ARGS_SPEC
02/10/2023 11:35:45 pygeoprocessing.geoprocessing INFO starting stats_worker
02/10/2023 11:35:45 pygeoprocessing.geoprocessing INFO started stats_worker <Thread(Thread-6 (stats_worker), started daemon 13057454080)>
02/10/2023 11:35:45 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator
Traceback (most recent call last):
File “natcap/invest/urban_flood_risk_mitigation.py”, line 809, in _lu_to_cn_op
File “<array_function internals>”, line 180, in choose
File “numpy/core/fromnumeric.py”, line 429, in choose
File “numpy/core/fromnumeric.py”, line 57, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “pygeoprocessing/geoprocessing.py”, line 443, in raster_calculator
File “natcap/invest/urban_flood_risk_mitigation.py”, line 816, in _lu_to_cn_op
ValueError: invalid entry in choice array
Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)
02/10/2023 11:35:45 pygeoprocessing.geoprocessing INFO Waiting for raster stats worker result.
02/10/2023 11:35:45 pygeoprocessing.geoprocessing_core WARNING No valid pixels were received, sending None.
02/10/2023 11:35:45 taskgraph.Task ERROR Something went wrong when adding task create Curve Number raster (1), terminating taskgraph.
Traceback (most recent call last):
File “natcap/invest/urban_flood_risk_mitigation.py”, line 809, in _lu_to_cn_op
File “<array_function internals>”, line 180, in choose
File “numpy/core/fromnumeric.py”, line 429, in choose
File “numpy/core/fromnumeric.py”, line 57, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “taskgraph/Task.py”, line 674, in add_task
File “taskgraph/Task.py”, line 1093, in _call
File “pygeoprocessing/geoprocessing.py”, line 443, in raster_calculator
File “natcap/invest/urban_flood_risk_mitigation.py”, line 816, in _lu_to_cn_op
ValueError: invalid entry in choice array
Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)
02/10/2023 11:35:45 natcap.invest.utils ERROR Exception while executing natcap.invest.urban_flood_risk_mitigation
Traceback (most recent call last):
File “natcap/invest/urban_flood_risk_mitigation.py”, line 809, in _lu_to_cn_op
File “<array_function internals>”, line 180, in choose
File “numpy/core/fromnumeric.py”, line 429, in choose
File “numpy/core/fromnumeric.py”, line 57, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “natcap/invest/utils.py”, line 164, in prepare_workspace
File “invest/cli.py”, line 486, in main
File “natcap/invest/urban_flood_risk_mitigation.py”, line 232, in execute
File “taskgraph/Task.py”, line 674, in add_task
File “taskgraph/Task.py”, line 1093, in _call
File “pygeoprocessing/geoprocessing.py”, line 443, in raster_calculator
File “natcap/invest/urban_flood_risk_mitigation.py”, line 816, in _lu_to_cn_op
ValueError: invalid entry in choice array
Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)
02/10/2023 11:35:45 natcap.invest.utils INFO Elapsed time: 0.41s
02/10/2023 11:35:45 natcap.invest.utils INFO Execution finished

Here I will attach the data inputs I am using:
Land use raster:
dea-export_raster.tif (18.8 KB)
Soil raster (I have tried multiple versions of this, but this is the one I am currently trying to use):
scs_soil_class_test.tif (146.6 KB)

Rainfall depth: 12mm

The area of interest is a shapefile of sub-watersheds in Johannesburg.

Thank you so much.

Welcome to the forum @JosephFreimond, and thanks for posting your logfile and data.

Looking at scs_soil_class_test.tif in a GIS, it contains values of 0, 2, 3 and 4. It looks like 0 might be a background value, not intended to be valid soil group data. So you might try setting your NoData value to 0 and see if that helps.

~ Stacie

1 Like

Hello Stacie, thank you so much for your help. I managed to get it to work.

1 Like

Hi everyone,

I am running into the same problem plus a different one.
My model is for the subwatersheds of Stockholm, Sweden. When trying to run the model I am getting the following log:

05/01/2023 11:54:16 osgeo WARNING [errno 1] The definition of projected CRS EPSG:3006 got from GeoTIFF keys is not the same as the one from the EPSG registry, which may cause issues during reprojection operations. Set GTIFF_SRS_SOURCE configuration option to EPSG to use official parameters (overriding the ones from GeoTIFF keys), or to GEOKEYS to use custom values from GeoTIFF keys and drop the EPSG code.

This message is repeated 9 times and then the log goes on as follows:

05/01/2023 11:54:20 pygeoprocessing.geoprocessing INFO 2 of 2 aligned: aligned_soils_hydrological_group_UFRM_noEcon_1.tif
05/01/2023 11:54:20 pygeoprocessing.geoprocessing INFO aligned all 2 rasters.
05/01/2023 11:54:20 pygeoprocessing.geoprocessing INFO starting stats_worker
05/01/2023 11:54:20 pygeoprocessing.geoprocessing INFO started stats_worker <Thread(Thread-6 (stats_worker), started daemon 13156)>
05/01/2023 11:54:20 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator
Traceback (most recent call last):
File “natcap\invest\urban_flood_risk_mitigation.py”, line 910, in _lu_to_cn_op
File “<array_function internals>”, line 200, in choose
File “numpy\core\fromnumeric.py”, line 429, in choose
File “numpy\core\fromnumeric.py”, line 57, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “pygeoprocessing\geoprocessing.py”, line 517, in raster_calculator
File “natcap\invest\urban_flood_risk_mitigation.py”, line 917, in _lu_to_cn_op
ValueError: invalid entry in choice array
Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)
05/01/2023 11:54:20 pygeoprocessing.geoprocessing INFO Waiting for raster stats worker result.
05/01/2023 11:54:20 pygeoprocessing.geoprocessing_core WARNING No valid pixels were received, sending None.
05/01/2023 11:54:20 taskgraph.Task ERROR Something went wrong when adding task create Curve Number raster (1), terminating taskgraph.
Traceback (most recent call last):
File “natcap\invest\urban_flood_risk_mitigation.py”, line 910, in _lu_to_cn_op
File “<array_function internals>”, line 200, in choose
File “numpy\core\fromnumeric.py”, line 429, in choose
File “numpy\core\fromnumeric.py”, line 57, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in _call
File “pygeoprocessing\geoprocessing.py”, line 517, in raster_calculator
File “natcap\invest\urban_flood_risk_mitigation.py”, line 917, in _lu_to_cn_op
ValueError: invalid entry in choice array
Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)
05/01/2023 11:54:20 natcap.invest.utils ERROR Exception while executing natcap.invest.urban_flood_risk_mitigation
Traceback (most recent call last):
File “natcap\invest\urban_flood_risk_mitigation.py”, line 910, in _lu_to_cn_op
File “<array_function internals>”, line 200, in choose
File “numpy\core\fromnumeric.py”, line 429, in choose
File “numpy\core\fromnumeric.py”, line 57, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 164, in prepare_workspace
File “invest\cli.py”, line 469, in main
File “natcap\invest\urban_flood_risk_mitigation.py”, line 333, in execute
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in _call
File “pygeoprocessing\geoprocessing.py”, line 517, in raster_calculator
File “natcap\invest\urban_flood_risk_mitigation.py”, line 917, in _lu_to_cn_op
ValueError: invalid entry in choice array
Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)
05/01/2023 11:54:20 natcap.invest.utils INFO Elapsed time: 5.17s
05/01/2023 11:54:20 natcap.invest.utils INFO Execution finished

If I understand correctly, something is off with the coordinate system of my .tif files, and there is a problem with my soil hydrologic raster, that the grouping is not correct. Here already a screenshot of the attribute table of my soil hydrologic raster, as you can see there are two different OIDs for group 4, due to reclassification from B/D and C/D group to D. Is that the potential source of the problem?

image

Apart from that, here is my other input data:

AoI_Stockholm_subwatersheds.zip (250.4 KB)

Rainfall depth: 105.7

LC_Stockholm_subwatersheds.zip (1.8 MB)

BiophysicalTable_UFRM_Stockholm.csv (2.7 KB)

SoilGroups_Stockholm.zip (11.3 KB)

I hope this is all the necessary information. Any help with this would be much appreciated, thanks in advance!
Maurizia

Solved!

I had overlooked that InVEST is working with numbers from the “Value” column, not with the “HySoilTyp_”. So after reclassifying the numbers in the “Value” column the model now runs smoothly!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.