NDR model Key error 1.0

Hello again!
I am running the NDR model for both N and P. I had a first run for N, which worked, then I had found data for P and did the same run, repeating N and P together and separately. However, although N did work the first time, now I keep getting this error (for both N and P separately and together in the same run) KEY ERROR 1.0. It is strange as I am using the very same layers, and the same biophysical table that worked for N the first time. I attach the log. Any idea of what kind of error it may be?
Thanks a lot, this forum is great and you are all very helpful!

LuisaInVEST-Nutrient-Delivery-Ratio-Model-(NDR)-log-2020-06-24–15_04_31.txt (304.5 KB)

Hi @luisagalgani -

As mentioned elsewhere on the forum, KeyErrors usually happen when there is a value in the land use map that is not included in the biophysical table. In this case the value is 1, but if it successfully ran with N before, I’m guessing that a missing value is not the problem.

When the model ran successfully with N, did the log file have all of those warnings about blank lines in the biophysical table? It used to be that blank lines at the end of the table caused problems for InVEST, and I’m not sure if this has been fixed (since there’s now a specific warning about it) or not. One thing you can try is to remove all of the blank lines in a text editor (since we can’t see them easily with Excel) and see if that helps.

If it doesn’t help, you can send me your inputs and I’ll check them out: swolny at stanford.edu.

~ Stacie

Hi Stacie, thanks for your message! No, the problem is not that a value in the LU map is not included in the biophysical table, because I have used the same biophysical table and the same land use map also for the N run that worked.
I found out what has changed: in the InVEST NDR guide, for the eff_n and eff_p, it is written that it has to be a floating point between 0 and 1.
When I run the model with these values in the biophysical table, for both eff_n and eff_p between 0 and 1, the model does not work and I get the key error message and the log file has all of those warnings about blank lines in the biophysical table.
If instead I use values as % (e.g. 0.8 --> 80), as found in some examples below “eff_n” in the nutrient_db_0212.xlsx file (the NaCap database) then the model runs successfully. Just this difference. But I do not know if these results I get are ok. What do you think?
Many thanks in advance!
Have a good day
Luisa

Hi @luisagalgani -

Interesting… But the eff_n values should be given as decimals for the model to calculate properly, so 80% would be entered into the table as 0.8.

Can you send me the input data that gives the error? Is the only difference between your runs checking the box for N versus checking the box for both N and P in the input interface?

~ Stacie

Thanks for sending me your data, Luisa. The problem is indeed with blank lines the CSV table. I got the same error you did, so opened the CSV in a text editor, copied only the lines with valid lucode values to a new file, saved the new file as CSV, and the model ran just fine for both N and P using this new CSV. (I would have just deleted the blank lines but there are a zillion of them.) Let me know if this works for you too.

~ Stacie

Dear Stacie,
thank you so much for your help. I did as you suggested and it worked! :smiley: Indeed, the blank lines caused the problem and I was not able to see them in excel.
Thanks again and have a great day

Luisa

Great! Glad to hear it, Luisa, thanks for letting me know.

~ Stacie

Thanks @swolny and @luisagalgani, we’ll make sure to add a test for blank lines in how we load CSV files.

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