# Urban flood risk mitigation, soil group raster error?

**URL:** <https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407>\
**Category:** Software Support\
**Tags:** urban-flood\
**Created:** [February 10, 2023, 9:56am UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407 "2023-02-10T09:56:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosephFreimond](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@JosephFreimond](https://community.naturalcapitalalliance.org/u/JosephFreimond)\
**Post date:** [February 10, 2023, 9:56am UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407/1 "2023-02-10T09:56:48Z")

</div>

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](https://community.naturalcapitalalliance.org/uploads/short-url/1vQP6LVD1sJ2sTzKYxewnwbXNp0.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](https://community.naturalcapitalalliance.org/uploads/short-url/iErkAaD11rJxdr6FTY9wCOyAUtD.tif) (146.6 KB)

Rainfall depth: 12mm

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

Thank you so much.

---

<div class="post-metadata">

**Author:** ![swolny](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/swolny/32/181_2.png) [@swolny](https://community.naturalcapitalalliance.org/u/swolny)\
**Post date:** [February 13, 2023, 4:54pm UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407/2 "2023-02-13T16:54:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JosephFreimond](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@JosephFreimond](https://community.naturalcapitalalliance.org/u/JosephFreimond)\
**Post date:** [February 15, 2023, 7:47am UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407/3 "2023-02-15T07:47:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Maurizia](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Maurizia](https://community.naturalcapitalalliance.org/u/Maurizia)\
**Post date:** [May 1, 2023, 10:51am UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407/4 "2023-05-01T10:51:00Z")

</div>

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](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/e/e03ae32051cd1b928ba96a095d64f37dc5a1ca81.png)

Apart from that, here is my other input data:

[AoI\_Stockholm\_subwatersheds.zip](https://community.naturalcapitalalliance.org/uploads/short-url/uXrAZaEdDvx4o8dzNGtPORS7sxP.zip) (250.4 KB)

Rainfall depth: 105.7

[LC\_Stockholm\_subwatersheds.zip](https://community.naturalcapitalalliance.org/uploads/short-url/cF9HtwMnPL1GFR1R4eTbH8vmdfv.zip) (1.8 MB)

[BiophysicalTable\_UFRM\_Stockholm.csv](https://community.naturalcapitalalliance.org/uploads/short-url/tSOAA05TrJeFzqiMT686X3ZJe5Z.csv) (2.7 KB)

[SoilGroups\_Stockholm.zip](https://community.naturalcapitalalliance.org/uploads/short-url/2MdO6KBFpsiYUD7l5bi6DEKMH2e.zip) (11.3 KB)

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

---

<div class="post-metadata">

**Author:** ![Maurizia](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Maurizia](https://community.naturalcapitalalliance.org/u/Maurizia)\
**Post date:** [May 5, 2023, 11:41am UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407/5 "2023-05-05T11:41:23Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/naturalcapitalproject/original/2X/8/8d95591aa074da87ea0fdd61ca47c1c3c0588aa7.png) [@system](https://community.naturalcapitalalliance.org/u/system)\
**Post date:** [May 12, 2023, 11:41am UTC](https://community.naturalcapitalalliance.org/t/urban-flood-risk-mitigation-soil-group-raster-error/3407/6 "2023-05-12T11:41:33Z")

</div>

Closed on May 12, 2023, 11:41am UTC

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