Urban flood risk mitigation IndexError

Hi there,
I am trying to run the urban flood risk mitigation model in Beijing, China. I have found data sources for all the inputs, however, the data seems not acceptable for the model.
I have uploaded all input sources in google drive. Can you kindly check them up for me?
https://drive.google.com/drive/folders/15I8gi9k6yFBzhYAXrE3GOZrhhvxi1HXC?usp=sharing

Thanks for the help,

Maryam

Hi @mhyuan , thanks for posting. Could you tell us what the model reports for these data sources? If there is a “red X” next to the Run button, what does it say when you click it? You can upload a screenshot here if that is helpful.

Thanks,
Dave

Dear Dave,
Thanks for your suggestions. I have checked the red x box and figured out the projection issue. Now it comes to another problem: Index Error countered: index (127) out of range.
All input documents have been upload here: 1013 - Google Drive
Please see the messages below.
Thanks for your assistance.
Maryam

Initializing…
Showing messages with level INFO and higher
2021-10-13 15:07:52,527 utils.prepare_workspace(123) INFO Writing log messages to C:/Users/admin/Documents/ArcGIS/Projects/MyProject8\InVEST-UrbanFloodRiskMitigation-log-2021-10-13–15_07_52.txt
2021-10-13 15:07:52,528 model._logged_target(1646) Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.urban_flood_risk_mitigation 3.9.0:
aoi_watersheds_path C:/Users/admin/Documents/ArcGIS/Projects/MyProject8/beijinginputwaterprojection.shp
built_infrastructure_vector_path
curve_number_table_path C:/Users/admin/Documents/ArcGIS/Projects/MyProject8/Biophysical.csv
infrastructure_damage_loss_table_path
lulc_path C:/Users/admin/Documents/ArcGIS/Projects/MyProject8/Beijing_lulc.tif
n_workers -1
rainfall_depth 1
results_suffix
soils_hydrological_group_raster_path C:/Users/admin/Documents/ArcGIS/Projects/MyProject8/Beijing_hysoil1.tif
workspace_dir C:/Users/admin/Documents/ArcGIS/Projects/MyProject8

2021-10-13 15:07:52,531 validation._wrapped_validate_func(915) INFO Starting whole-model validation with ARGS_SPEC
2021-10-13 15:07:52,614 usage._log_model(245) WARNING an exception encountered when logging ValueError(‘Could not open as a gdal.OF_VECTOR’)
2021-10-13 15:07:52,749 utils.build_lookup_from_csv(528) WARNING Empty or NaN values were found in the table: C:/Users/admin/Documents/ArcGIS/Projects/MyProject8/Biophysical.csv.
2021-10-13 15:07:52,763 geoprocessing.raster_calculator(391) INFO starting stats_worker
2021-10-13 15:07:52,764 geoprocessing.raster_calculator(397) INFO started stats_worker <Thread(Thread-509, started daemon 6324)>
2021-10-13 15:07:52,766 geoprocessing.raster_calculator(507) INFO Waiting for raster stats worker result.
2021-10-13 15:07:52,766 threading.run(870) WARNING No valid pixels were received, sending None.
2021-10-13 15:07:52,767 Task.add_task(781) ERROR Something went wrong when adding task create Curve Number raster (1), terminating taskgraph.
Traceback (most recent call last):
File “site-packages\taskgraph\Task.py”, line 747, in add_task
File “site-packages\taskgraph\Task.py”, line 1234, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 438, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 775, in _lu_to_cn_op
File “site-packages\scipy\sparse_index.py”, line 35, in getitem
File “site-packages\scipy\sparse_index.py”, line 139, in _validate_indices
File “site-packages\scipy\sparse_index.py”, line 171, in _asindices
IndexError: index (127) out of range
2021-10-13 15:07:52,767 model._logged_target(1652) ERROR Exception while executing <function execute at 0x000001920F658948>
Traceback (most recent call last):
File “site-packages\natcap\invest\ui\model.py”, line 1649, in _logged_target
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 241, in execute
File “site-packages\taskgraph\Task.py”, line 747, in add_task
File “site-packages\taskgraph\Task.py”, line 1234, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 438, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 775, in _lu_to_cn_op
File “site-packages\scipy\sparse_index.py”, line 35, in getitem
File “site-packages\scipy\sparse_index.py”, line 139, in _validate_indices
File “site-packages\scipy\sparse_index.py”, line 171, in _asindices
IndexError: index (127) out of range
2021-10-13 15:07:52,767 model._logged_target(1655) INFO Execution finished
2021-10-13 15:07:52,769 utils.prepare_workspace(129) INFO Elapsed time: 0.24s
2021-10-13 15:07:52,770 execution.run(78) ERROR Target <function InVESTModel.execute_model.._logged_target at 0x0000019212F250D8> failed with exception
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 1649, in _logged_target
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 241, in execute
File “site-packages\taskgraph\Task.py”, line 747, in add_task
File “site-packages\taskgraph\Task.py”, line 1234, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 438, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 775, in _lu_to_cn_op
File “site-packages\scipy\sparse_index.py”, line 35, in getitem
File “site-packages\scipy\sparse_index.py”, line 139, in _validate_indices
File “site-packages\scipy\sparse_index.py”, line 171, in _asindices
IndexError: index (127) out of range
2021-10-13 15:07:52,770 execution.run(83) INFO Execution finished

Hi @mhyuan , thanks for sharing your log and your data. The problem here is that there are values in the LULC raster that do not appear in the biophysical table. Specifically, the raster has values of 0 and 127 that are missing from the table. So your options are either 1) add rows for those two values in the biophysical table, or 2) do some reclassification on the LULC raster.

As I look at the LULC raster, option 2 is probably best because both 0 and 127 appear to represent “nodata”. But the raster does not have a “nodata” value defined. So I might reclassify the 127 pixels to 0 and then set the nodata value for the raster as 0. If you do that, you should not need to modify the biophysical table.

Good luck!

1 Like

Dear Dave,
Thanks for your support and assistance. It works!!