ValueError: invalid entry in choice array: Urban Flood Risk Mitigation

Hello, it’s my first time using Invest,
I saved Parameter and data (.tgz file that I upload)

I am trying to run the urban flood risk mitigation model, but whenever I try to run this errors appears:

03/02/2025 17:48:21 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator
Traceback (most recent call last):
File “natcap\invest\urban_flood_risk_mitigation.py”, line 892, in _lu_to_cn_op
File “numpy_core\fromnumeric.py”, line 455, 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 475, in raster_calculator
File “natcap\invest\urban_flood_risk_mitigation.py”, line 899, 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)
03/02/2025 17:48:21 pygeoprocessing.geoprocessing INFO Waiting for raster stats worker result.
03/02/2025 17:48:21 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 892, in _lu_to_cn_op
File “numpy_core\fromnumeric.py”, line 455, 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 “src\pygeoprocessing\geoprocessing_core.pyx”, line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “pygeoprocessing\geoprocessing.py”, line 475, in raster_calculator
File “natcap\invest\urban_flood_risk_mitigation.py”, line 899, 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)
03/02/2025 17:48:21 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 892, in _lu_to_cn_op
File “numpy_core\fromnumeric.py”, line 455, 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 186, in prepare_workspace
File “invest\cli.py”, line 472, in main
File “natcap\invest\urban_flood_risk_mitigation.py”, line 325, in execute
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in _call
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “pygeoprocessing\geoprocessing.py”, line 475, in raster_calculator
File “natcap\invest\urban_flood_risk_mitigation.py”, line 899, 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)
03/02/2025 17:48:21 natcap.invest.utils INFO Elapsed time: 0.15s
03/02/2025 17:48:21 natcap.invest.utils INFO Execution finished; version: 3.14.3
Could you help me, please?

Hi @YohanaMora -

The log file includes this line:

Check that the Soil Group raster does not contain values other than (1, 2, 3, 4)

As the User Guide also notes, the Soil Group raster may only contain values 1-4. Have you checked that this is the case for your soil group input raster?

Sometimes soil group data contains values like 14, indicating dual soil groups A/D etc. These need to be converted into one of the valid values 1-4. The User Guide provides some guidance about what to consider when converting these values.

If it looks like your soil group raster only does have values 1-4, then it would be useful if you’d upload that file (or point us to it somewhere on cloud storage) and I’ll check it out.

~ Stacie

Thanks.

Hello, I changed the groupsoil raster but now the problem is this:
03/03/2025 11:47:46 pygeoprocessing.geoprocessing INFO poly intersection lookup approximately 2.2% complete on reprojected_aoi
03/03/2025 11:47:51 taskgraph.Task ERROR A taskgraph _task_executor failed on Task zonal_statistics over runoff_retention raster (9). Terminating taskgraph.
multiprocessing.pool.RemoteTraceback:
“”"
Traceback (most recent call last):
File “multiprocessing\pool.py”, line 125, in worker
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “pygeoprocessing\geoprocessing.py”, line 1803, in zonal_statistics
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “pygeoprocessing\geoprocessing.py”, line 2881, in calculate_disjoint_polygon_set
File “shapely\prepared.py”, line 57, in intersects
File “shapely\geometry\base.py”, line 719, in intersects
File “shapely\decorators.py”, line 77, in wrapped
File “shapely\predicates.py”, line 778, in intersects
shapely.errors.GEOSException: bad allocation
“”"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “taskgraph\Task.py”, line 461, in _task_executor
File “taskgraph\Task.py”, line 1090, in _call
File “multiprocessing\pool.py”, line 774, in get
shapely.errors.GEOSException: bad allocation
03/03/2025 11:47:51 natcap.invest.utils ERROR Exception while executing natcap.invest.urban_flood_risk_mitigation
multiprocessing.pool.RemoteTraceback:
“”"
Traceback (most recent call last):
File “multiprocessing\pool.py”, line 125, in worker
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “pygeoprocessing\geoprocessing.py”, line 1803, in zonal_statistics
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “src\pygeoprocessing\geoprocessing_core.pyx”, line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper
File “pygeoprocessing\geoprocessing.py”, line 2881, in calculate_disjoint_polygon_set
File “shapely\prepared.py”, line 57, in intersects
File “shapely\geometry\base.py”, line 719, in intersects
File “shapely\decorators.py”, line 77, in wrapped
File “shapely\predicates.py”, line 778, in intersects
shapely.errors.GEOSException: bad allocation
“”"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “natcap\invest\utils.py”, line 186, in prepare_workspace
File “invest\cli.py”, line 472, in main
File “natcap\invest\urban_flood_risk_mitigation.py”, line 497, in execute
File “taskgraph\Task.py”, line 1299, in get
File “taskgraph\Task.py”, line 1272, in join
File “taskgraph\Task.py”, line 461, in _task_executor
File “taskgraph\Task.py”, line 1090, in _call
File “multiprocessing\pool.py”, line 774, in get
shapely.errors.GEOSException: bad allocation

I had changed to raster pixels for 300m X 300 m but the problem persists. ¿Can be my PC the problem?

This link contains the folder with parameter and data that I am using now:

Thank you so much for your help

Hi @YohanaMora , and I’m sorry about the delay in our response here. Are you still experiencing this issue?

The main thing that comes to mind when looking at your logs here is that there is most likely a geometry that is invalid. If you are still experiencing this issue, I would suggest using a GIS tool to make sure that your vector geometries are all in good order, such as with a geometry repair and/or verification tool. If the issue persists, please let us know!

James

Thanks for you answer. The problem was solved when I uninstalled Invest and Installed again.