InVEST 3.11.0 error while running SWY, the keyerror is 13

Hello everyone,

I am getting an error when using inVEST for SWY run. Next is the error code. I don’t know how to fix it, I would like some help. Among them, there is no 0 value in my LULC layer.

09/09/2022 10:53:37 pygeoprocessing.geoprocessing INFO starting stats_worker
09/09/2022 10:53:37 pygeoprocessing.geoprocessing INFO started stats_worker
09/09/2022 10:53:37 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator
Traceback (most recent call last):
File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 1101, in cn_op
KeyError: 13
09/09/2022 10:53:37 pygeoprocessing.geoprocessing INFO Waiting for raster stats worker result.
09/09/2022 10:53:37 pygeoprocessing.geoprocessing_core WARNING No valid pixels were received, sending None.
09/09/2022 10:53:37 taskgraph.Task ERROR Something went wrong when adding task calculate curve number (7), terminating taskgraph.
Traceback (most recent call last):
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in _call
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 1109, in _calculate_curve_number_raster
File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 1101, in cn_op
KeyError: 13
09/09/2022 10:53:37 natcap.invest.utils ERROR Exception while executing natcap.invest.seasonal_water_yield.seasonal_water_yield
Traceback (most recent call last):
File “natcap\invest\utils.py”, line 165, in prepare_workspace
File “natcap\invest\cli.py”, line 486, in main
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 408, in execute
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 665, in _execute
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in _call
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 1109, in _calculate_curve_number_raster
File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator
File “natcap\invest\seasonal_water_yield\seasonal_water_yield.py”, line 1101, in cn_op
KeyError: 13
09/09/2022 10:53:37 natcap.invest.utils INFO Elapsed time: 0.4s
09/09/2022 10:53:37 natcap.invest.utils INFO Execution finished

thanks

Could you make sure that you have a row in your biophysical table representing lucode 13? This is the most likely reason why you are experiencing this error.

Yes, there is code 13 in my LULC. I think it refers to the keyerror code 13, not the LULC code. But there is a problem with CN(7) later, I don’t know which one it is.

HI @Lanuop,

Usually KeyErrors occur in InVEST models when a LULC raster input has values that do not exactly match to a table input column in a corresponding Biophysical table.

Yes, there is code 13 in my LULC

Great, is there also a matching 13 in the biophysical table under lucode? Would you mind sharing the biophysical table input?

Cheers,

Doug

Sorry, I forgot to reply. I double checked all the data, the projection of the water and soil data except the problem. My biophysics table is fine. Thank you!

1 Like

Sorry, I can already run it successfully. Thank you!

1 Like

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