NDR InVEST 3.7 and 3.5 KeyError: 0

I am using InVEST 3.5 and 3.7 NDR and always getting an error KeyError: 0, already veryfied the projection of files and also the biophysical table, but still getting the error in both versions. What I am doing wrong and how can I fix it? Thanks for your help! InVEST-Nutrient-Delivery-Ratio-Model-(NDR)-log-2019-09-27–16_07_28.txt (23.1 KB) InVEST-Nutrient-Delivery-Ratio-Model-(NDR)-log-2019-09-27–17_09_58.txt (25.5 KB)

Hi @brunoos -

The error seems to be happening when mapping the load values from the coefficient table to the land use/land cover map. And you’ve verified that you don’t have a value of 0 in your land cover map that’s missing in the coefficient table, and that all of the inputs are in a projected coordinate system. So another thing to check is the format of the coefficient table. Make sure that the column values are separated by commas, not semicolons, and if there’s a blank line at the end of the file, delete it (do both of these things in a text editor, not Excel, since we can’t see either of those issues in Excel.)

One other issue sometimes has to do with the land cover map not having a NoData value, so make sure that it does. And one final thing you can try is actually adding a value of 0 to your coefficient table and give that row all values of 1 or something, try to run and see if that helps.

Let us know if any of these work, and if none of them do, if you send me your input data I’ll check it out.

~ Stacie

1 Like

Hey @swolny

Thanks for your helpful support as always! It did work by creating a new raster dataset from a polygon LCLU feature and a new bio coefficient table corresponding to the values for that same new dataset. All other tries following your recommendations did not reach a final before the model runs normally. Even tough, when assuming some modifications and running into multiple tries, two new errors arise: KeyError 9 and KeyError 19. Also, I run two different LCLU maps from two different years with the same parameters. However, in one I got the aligned_x tif outputs and in the other just the standard x_export tif and the watershed shp. All inputs rather the LCLU maps were the same.

Yet, I have non-technical questions if you guys don´t mind! Maybe it can be addressed to another NatCap member. Even if I accessed another post with a reply on how to interpret and use the results accordingly, hereby I ask:

  • I want to summarize the model results, meaning that I am also interesting not only in individualize p and n, but also in get to know and share the results of water quality regulation considering together both p and n. Assuming that in the TOC of the output watershed shp we have n and p exp_tot and load_tot fields, how is the correct form to a) access the nutrient deliver ratio and b) the total amount of nutrient retained.

Just to contextualize, I want to see the differences between two moments on time t0 and t1 considering p and n as one (to access the nutrients as a whole), and most of all, to calculate and to understand the occurred variation.

I hope it makes sense!

Thank you so much once again community!

Best wishes for a great week!