Key Error: ''cn_a'' Seasonal Water Yield Model

Hello everyone
Please may I be assisted with correcting this error. Have been running the SWY model on the InVEST version 3.12.0. And I have been receiving the following error message:
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 164, in prepare_workspace**
** File “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 440, in _execute**
KeyError: ‘cn_a’

I have checked the biophysical table for any inconsistences but have not been able to identify any. Also made changes to the soil groups raster. Your assistance is highly appreciated.

Regards,
Simphiwe

Hi @Simphiwe, and welcome to the forum! -

Please post the entire log file (with a long name that ends in .txt) that is created in your Workspace. That might have additional information to help us debug.

If you have already checked that you have the correct column names, and the value entries are separated by commas, you could also post your biophysical table here so we can take a look at it. Thanks.

~ Stacie

Hello Stacie

Thank you so much, I have now attached both the log file and biophysical table.
InVEST-natcap.invest.seasonal_water_yield.seasonal_water_yield-log-2022-11-02–08_02_09.txt (2.5 KB)
Biophysical table .csv (1.1 KB)

Thanks,
Simphiwe

Hi @Simphiwe,
Your biophysical table column names are incorrect. The soil groups must be prefixed with cn_: cn_acn_d. The months must be prefixed with kc_: kc_1kc_12.

Columns:

  • lucode (integer, required): LULC code matching those in the LULC raster.
  • cn_[SOIL_GROUP] (number, units: unitless, required): Curve number values for each combination of soil group and LULC class. Replace [SOIL_GROUP] with each soil group code A, B, C, D so that there is one column for each soil group. Curve number values must be greater than 0.
  • kc_[MONTH] (number, units: unitless, required): Crop/vegetation coefficient (Kc) values for this LULC class in each month. Replace [MONTH] with the numbers 1 to 12 so that there is one column for each month.

Hello @esoth
Thank you so much for the assistance.

Thanks
Simphiwe

Thank you so much, I have been able to correct the biophysical table and run the model, but I keep getting errors. I have a question pertaining the ETo raster directory, the one I am using is giving me No value errors. Please may I get the recommended sources for it.
InVEST-natcap.invest.seasonal_water_yield.seasonal_water_yield-log-2022-11-03–06_08_38.txt (3.0 KB)

I have attached the log file.

Thanks,
Simphiwe

HI @Simphiwe -

How did you name your ET0 rasters? The error message says this:
ValueError: No et0 found for month 2

And the User Guide says this:
Evapotranspiration (units: mm, required): Twelve files, one for each month. File names must end with the month number (1-12). For example, the filenames ‘et0_1.tif’ ‘evapotranspiration1.tif’ are both valid for the month of January.

So do you have a file named something like “et0_2.tif” (and “et0_3.tif” etc, one for each month)?

~ Stacie

Hi @swolny
Yes, the files are named as stated in the User Guide.

Regards
Simphiwe

Ok, then can you send me all of your input files so I can take a look at them? You can send them to me at swolny@stanford.edu.

~ Stacie

1 Like