Urban Flood Risk Mitigation - Soil Group Raster preparation error?

Hello!

First of all, I know that a similar topic already has been posted (Urban Flood Mitigation Error - ValueError: invalid entry in choice array) whereas a result, I think you did include the error message that I see now.

After initially running my model, the tool aborted after a few seconds with the error message of 'Value Error encountered: Invalid entry in choice array. Check that the Soil Group Raster does not contain values other than (1,2,3,4).

The problem is, that my soil group raster DOES NOT contain any other values than 1-4.

Screencap where you can see the attribute table of the soil raster:

Any idea what the problem could be? Maybe the error lies somewhere else?
I further tried creating a new, artificial soil raster file containing just 1 single soil type for the whole area of interest (only containing value 3, just like the example data), but ended up getting the same error nonetheless, so I suspect the problem might be a different one?

Log details:

Initializing…
Showing messages with level INFO and higher
2020-06-15 11:53:34,886 utils.prepare_workspace(111) INFO Writing log messages to D:/InVEST/The Hague Runs/Flooding/Run/Test1\InVEST-UrbanFloodRiskMitigation-log-2020-06-15–11_53_34.txt
2020-06-15 11:53:34,887 model._logged_target(1629) Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.urban_flood_risk_mitigation 3.8.2:
aoi_watersheds_path D:/InVEST/The Hague Runs/Flooding/Data/MiniHague.shp
built_infrastructure_vector_path
curve_number_table_path D:/InVEST/The Hague Runs/Flooding/Data/Biophysical Table.csv
infrastructure_damage_loss_table_path
lulc_path D:/InVEST/The Hague Runs/Flooding/Data/LULC_10x10_Hague.tif
n_workers -1
rainfall_depth 8
results_suffix test
soils_hydrological_group_raster_path D:/InVEST/The Hague Runs/Flooding/Data/Soilgroups_NA.tif
workspace_dir D:/InVEST/The Hague Runs/Flooding/Run/Test1

2020-06-15 11:53:35,006 geoprocessing.raster_calculator(375) INFO starting stats_worker
2020-06-15 11:53:35,007 geoprocessing.raster_calculator(381) INFO started stats_worker <Thread(Thread-15, started daemon 16624)>
2020-06-15 11:53:35,032 geoprocessing.raster_calculator(486) INFO Waiting for raster stats worker result.
2020-06-15 11:53:35,033 threading.run(870) WARNING No valid pixels were received, sending None.
2020-06-15 11:53:35,033 Task.add_task(626) ERROR Something went wrong when adding task create cn raster (1), terminating taskgraph.
Traceback (most recent call last):
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 828, in _lu_to_cn_op
File “<array_function internals>”, line 6, in choose
File “site-packages\numpy\core\fromnumeric.py”, line 433, in choose
File “site-packages\numpy\core\fromnumeric.py”, line 61, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “site-packages\taskgraph\Task.py”, line 592, in add_task
File “site-packages\taskgraph\Task.py”, line 1069, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 424, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 832, 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)
2020-06-15 11:53:35,034 model._logged_target(1635) ERROR Exception while executing <function execute at 0x0FFA1C00>
Traceback (most recent call last):
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 828, in _lu_to_cn_op
File “<array_function internals>”, line 6, in choose
File “site-packages\numpy\core\fromnumeric.py”, line 433, in choose
File “site-packages\numpy\core\fromnumeric.py”, line 61, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “site-packages\natcap\invest\ui\model.py”, line 1632, in _logged_target
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 248, in execute
File “site-packages\taskgraph\Task.py”, line 592, in add_task
File “site-packages\taskgraph\Task.py”, line 1069, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 424, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 832, 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)
2020-06-15 11:53:35,035 model._logged_target(1638) INFO Execution finished
2020-06-15 11:53:35,041 utils.prepare_workspace(117) INFO Elapsed time: 0.16s
2020-06-15 11:53:35,058 execution.run(78) ERROR Target <function InVESTModel.execute_model.._logged_target at 0x01695A98> failed with exception
Traceback (most recent call last):
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 828, in _lu_to_cn_op
File “<array_function internals>”, line 6, in choose
File “site-packages\numpy\core\fromnumeric.py”, line 433, in choose
File “site-packages\numpy\core\fromnumeric.py”, line 61, in _wrapfunc
ValueError: invalid entry in choice array

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “site-packages\natcap\invest\ui\execution.py”, line 68, in run
File “site-packages\natcap\invest\ui\model.py”, line 1632, in _logged_target
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 248, in execute
File “site-packages\taskgraph\Task.py”, line 592, in add_task
File “site-packages\taskgraph\Task.py”, line 1069, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 424, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 832, 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)
2020-06-15 11:53:35,063 execution.run(83) INFO Execution finished

Thank you!

Hi @Milkiman

Thanks for posting and sorry you’re having trouble here. Would you be willing to share the LULC and Soil Group Raster inputs you are using? If you prefer not to upload here you can use a link to a shared drive or email me at ddenu@stanford.edu.

Doug

Hey, thanks for your help!

Yeah no worries, I will upload it here.

LULC_10x10_Hague.tif (2.0 MB)

Soilgroups_1_3_4.tif (1.0 MB)

Thanks @Milkiman,

I don’t see anything that would cause concern, could you provide the rest of your inputs for the model run? This could be a bug and running the model with your inputs would really help find it.

Thanks!

Oh weird!

Yes, so the watershed vector is just a placeholder shape file, as I yet have to finalize the actual watershed, but the final file should be somewhat similar in its extent/form…

The CSV file is already final and DOES work with the provided example data (as I CAN successfully run the example model with my own csv file), so I do not expect the error to be in there.

Watershed_ex.zip (2.0 KB)

Biophysical Table.csv (1.2 KB)

If you can successfully run the model with all of my data, the problem might be on my PC (although I did try with InVEST version 3.8.2 and 3.8.4, with a fresh install already, but same error always)

Thanks!

Hi @Milkiman

Sorry for the delay here. It looks like there is a bug that we’ll need to fix. In the meantime can you try setting the nodata value on your Soilgroups_1_3_4 raster to something other than 0? Maybe 7?

Please try that with InVEST 3.8.4 and let me know if it works.

Doug

Thanks for your help. I reclassified the soils group layer Class 0–>7 and managed to get it to work.
Howard

Thank you so far, good to know!

As of now, if I reclassify the nodata values to 7 using f.ex. the reclassify tool in ArcMap or using the raster calculator, I still get the same error as usual. Only if I assign nodata to either 1,2,3 or 4, I manage to get the model to run successfully.

For now I can work with that, but if anybody has any other input, feel free to comment. Maybe I need to reclassify the data in another manner, considering @hcambridge got it to run with the value 7? What spatial analysis software are you using?

I used QGIS to reclassify @Milkiman .
Howard

@Milkiman,

I’m happy to take a look at your reclassified soil data raster that’s still not working for you, to make sure there’s not something I overlooked.

Doug

@dcdenu4

I finally got it to work now by reclassifying all NoData values of [Soilgroups_1_3_4] first to some number (e.g. 7), and then reclassifying all 7 values back to NoData (All with the reclassifying tool of ArcMap). I am not sure on why it works now, but I will upload the file so you may be able to find the reason for further troubleshooting…

Soilgroups_1_3_4_reclass.tif (2.0 MB)