Water yield key error

Hi,everyone,
I’ve met a problem about the Water Yield Model, about the value error as follows,
biophysical_table_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/biophysical table.csv
depth_to_root_rest_layer_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/root.tif
do_scarcity_and_valuation False
eto_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/ETO.tif
lulc_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/landuse.tif
n_workers -1
pawc_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/pawc.tif
precipitation_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/rain.tif
results_suffix 2020
seasonality_constant 15
sub_watersheds_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/shp/subwatershed.shp
watersheds_path C:/Users/huang/Desktop/Graduation/materials and data/InVEST_tgr/water_yield/shp/watershed.shp
workspace_dir C:\Users\huang\Desktop\Graduation\materials and data\InVEST_tgr\water_output

2022-05-01 20:34:32,190 hydropower_water_yield.execute(101) INFO Validating arguments
2022-05-01 20:34:32,237 validation._wrapped_validate_func(148) DEBUG Validation warnings: []
2022-05-01 20:34:32,269 geoprocessing.align_and_resize_raster_stack(729) INFO n_workers > 1 (2) so starting a processes pool.
2022-05-01 20:34:42,832 geoprocessing.align_and_resize_raster_stack(779) INFO 1 of 5 aligned: eto_2020.tif
2022-05-01 20:34:47,096 geoprocessing.align_and_resize_raster_stack(779) INFO 2 of 5 aligned: precip_2020.tif
2022-05-01 20:34:55,456 geoprocessing.align_and_resize_raster_stack(779) INFO 3 of 5 aligned: depth_to_root_rest_layer_2020.tif
2022-05-01 20:35:04,342 geoprocessing.align_and_resize_raster_stack(779) INFO 4 of 5 aligned: pawc_2020.tif
2022-05-01 20:35:07,857 geoprocessing.align_and_resize_raster_stack(779) INFO 5 of 5 aligned: clipped_lulc_2020.tif
2022-05-01 20:35:07,982 geoprocessing.align_and_resize_raster_stack(788) INFO aligned all 5 rasters.
2022-05-01 20:35:08,170 utils.build_lookup_from_csv(471) WARNING Encountered an entirely blank row on line 10
2022-05-01 20:35:08,184 utils.build_lookup_from_csv(471) WARNING Encountered an entirely blank row on line 11
2022-05-01 20:35:08,184 utils.build_lookup_from_csv(471) WARNING Encountered an entirely blank row on line 12
2022-05-01 20:35:08,184 hydropower_water_yield.execute(236) DEBUG bio_lucodes set([’’, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 0.0])
2022-05-01 20:35:08,184 hydropower_water_yield._check_missing_lucodes(724) INFO Checking that input tables have landcover codes for every value in the landcover map.
2022-05-01 20:35:11,388 hydropower_water_yield.execute(278) INFO Reclassifying temp_Kc raster
2022-05-01 20:35:11,404 Task.add_task(636) ERROR Something went wrong when adding task create_Kc_raster (2), terminating taskgraph.
Traceback (most recent call last):
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\taskgraph\Task.py”, line 602, in add_task
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\taskgraph\Task.py”, line 1068, in _call
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\pygeoprocessing\geoprocessing.py”, line 1747, in reclassify_raster
KeyError: ‘0.0’
2022-05-01 20:35:11,404 model._logged_target(1640) ERROR Exception while executing <function execute at 0x10EBC530>
Traceback (most recent call last):
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\natcap\invest\ui\model.py”, line 1637, in _logged_target
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\natcap\invest\hydropower\hydropower_water_yield.py”, line 287, in execute
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\taskgraph\Task.py”, line 602, in add_task
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\taskgraph\Task.py”, line 1068, in _call
File “Z:\opt\atlassian\pipelines\agent\build\env\lib\site-packages\pygeoprocessing\geoprocessing.py”, line 1747, in reclassify_raster
KeyError: ‘0.0’
2022-05-01 20:35:11,404 model._logged_target(1643) INFO Execution finished
2022-05-01 20:35:11,404 utils.prepare_workspace(115) INFO Elapsed time: 39.21s

If someone can solve the problem, I will be very grateful for that, thanks.
The error details file is also attached.
InVEST-Hydropower-Water-Yield-log-2022-05-01–20_34_32.txt (4.7 KB)

Hi @yajiaoban,

Thanks for including your log file with the post. The KeyError: 0.0 means that either the LULC input raster or the associated biophysical table do not recognize 0.0. Does your LULC raster have 0.0 values and does your table have a row to handle them? Sometimes we see this when the LULC rasters nodata value is not set.

I also see you’re using a development version of InVEST 3.6.0. We would strongly recommend updating to the latest version of InVEST 3.10.2. Many bugfixes and updates have been made across the software.

Best,

Doug

1 Like

Thanks, Doug, the problem has been resolved, thanks very much.

dcdenu4 via Natural Capital Project Online Community <notifications@naturalcapitalproject.discoursemail.com> 于2022年5月2日周一 09:12写道:

Sorry, I have another question, that is, does the input of raster images with different resolutions have any effect on the final result of the model, and is it necessary to standardize the resolution before data input?

thanks,

jin huang <huangjinjin0210@gmail.com> 于2022年5月2日周一 13:17写道:

Good question, the model standardizes and aligns all of the raster inputs for you, using the LULC raster input as the basis for the resolution, and a “nearest neighbor” resampling method. If you wish to have more control over the resampling methods used, you could certainly do this step yourself beforehand.

1 Like