Carbon Model - Carbon Model - KeyError Encountered: nan

Hello everyone,

I utilized a LULC map with 500m resolution for running the carbon model and everything worked fine. Now that I’ve improved the resolution to 100m I receive this error: Carbon Model - KeyError Encountered: nan

I used the same carbon pools. I attach here the log text file.

Thank you so much for your support!


InVEST-InVEST-Carbon-Model-log-2020-03-23–10_18_27.txt (2.8 KB)

Hi @marco.guzzetti,

Can you describe how you improved the resolution on your LULC raster? Something could have gone wrong in re-sampling and it might be worth pulling that file up in ArcGIS or QGIS and doing some symbolizing to see if anything stands out as “bad data”.

Let us know.


Hi @dcdenu4

so basically I’m using QGIS3.4 and I utilized the GRASS tool “r.resamp.Interp” (image). My goal was to go from 500m to 100m.


I don’t know if there are better tools that I could use.

Thank you,

Hi Marco -

The main thing to pay attention to is whether the resampling created any new values in the 100m LULC map that were not in the 500m version. If you used the “nearest” method, then it probably shouldn’t have, but look especially around the edges of the raster to make sure. The fact that the error is for “nan” and not an actual number is interesting - can you find any evidence of NaN actually being assigned to any raster cells?

~ Stacie

1 Like

Dear Stacie,

sorry if it took me a few days to reply but I confirm that you were right. I’ve found a few pixels with no value, so I suppose that this was the problem.

Thank you!


Great to hear Marco!