InVEST 3.9.0 NDR model: KeyError for lucode of land use and biophysical table


When I use the NDR model, I have a problem with the log file saying as follows:
KeyError: ‘lucode: -339999995214436424907732413799364296704 is present in the landuse raster but missing from the biophysical table’

However, I have checked my land use raster (landuse2009.tif) and biophysical table, all the lucodes are matched. Also, I have considered about the no data value and use ArcGIS raster calculator to convert all the nodata value into 0 (test41.tif), then I add 0 row in the biophysical table. There is still the same problem. In addition, all my lucode is from 112 to 512, so the lucode reported in the error is rather strange.

I would appreciated it if you could provide some help! I have attached my data and the whole input folder is shared through google drive.

InVEST-Nutrient-Delivery-Ratio-Model-(NDR)-log-2021-05-12–15_29_24.txt (9.5 KB)

Hi @Jiaying , thanks for posting. Since that value is very, very small, you could try using the raster calculator to convert all pixels < 0 to 0.

Thank you for your reply and it works! However, I am facing another problem ValueError: cannot convert float NaN to integer. I suppose the problem should be with biophysical table but have no clue. I attached my updated log file and the biophysical table.
biophysical_table1.csv (965 Bytes)
InVEST-Nutrient-Delivery-Ratio-Model-(NDR)-log-2021-05-12–23_36_11.txt (3.5 KB)

@Jiaying , I’m glad that worked. This error is basically the same as the last one, a raster value is not present in the table. But now the problematic raster value is nan.

There are no nan values in your input lulc, but there are nan values in intermediate_outputs/cache_dir/aligned_lulc.tif which is the intermediate dataset after the model aligns and projects all the input layers.

So, I’m concerned about the coordinate reference system of all the input layers. It may be missing some crucial information that breaks things. The CRS reads, in part

    BASEGEOGCRS["Unknown datum based upon the Bessel 1841 ellipsoid",
            ELLIPSOID["Bessel 1841",6377397.155,299.1528128,

I’m concerned about that unknown datum. Could you try projecting your input data (lulc, watershed, dem, etc) to a different CRS? A UTM system is usually a good choice.

Thanks for sharing your data.

Thank you for your suggestion!
Finally I worked it out and the error is because there is a small patch within the study area in the LU file with no data. After converting it to 0 the model is running successfully!

Great! It’s strange that the prior raster calculator operations did not convert these last nodata pixels. Maybe they had some other strange non-numeric value.

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