This forum is shutting down! Please post new discussions at

Seasonal Water Yield: error when writing output


I have been running the Seasonal Water Yield model for 1-2 watersheds and most recently I have run into this error: "KeyError encountered: 0". It occurred when the it was writing the output and I cannot figure out what is wrong. Any ideas? I attached the log for details.



  • swolnyswolny Member, NatCap Staff
    Hi @atutterow -

    Is it possible that you have a Value of 0 in your LULC raster that is not in your biophysical table? If so, you'll need to add the lucode 0 to your biophysical table and give it coefficient values.

    Or, are there any blank lines at the bottom of the biophysical table? You can see this most easily if you look at the table not in Excel, but in Notepad++ or another text editor. If so, delete the blank lines and try again.

    ~ Stacie
  • Hi @swolny,

    Thanks for your response! Unfortunately, it doesn't appear to be my BP table causing the error. I have run the model successfully with this same table multiple times before. The only change is that I cropped the DEM, LULC, and soil inputs to smaller regions to help the model run quickly. Any other ideas?

    Thank you!
  • All the QF values are calculated. 

    Something is going on in line 816:

    File "c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\seasonal_water_yield\", line 816, in _aggregate_recharge

    KeyError: 0

  • swolnyswolny Member, NatCap Staff
    Does your watershed shapefile have a "ws_id" field with a unique integer value? If it's aggregating, it could be something related to that shapefile.

    ~ Stacie
  • Yes, it was the watershed shapefile. Thank you!
Sign In or Register to comment.