NDR KeyError: 5

Thanks a lot @jesseG
I have also an error, could you plz help me in this case?KeyError: 5 of NDR model.


03/17/2022 20:45:14 natcap.invest.utils INFO Writing log messages to D:\PHD THESIS\ENV\Prof. Peter Mederly\FATEMEH\NDR\InVEST-Nutrient-Delivery-Ratio-Model-(NDR)-log-2022-03-17–20_45_14.txt
03/17/2022 20:45:14 natcap.invest.ui.model Level 100 Starting model with parameters:
Arguments for InVEST natcap.invest.ndr.ndr 3.4.0:
biophysical_table_path D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/SHP DATA FOR NITRA/InVEST_lulc_biophysical_table_gura.csv
calc_n True
calc_p False
dem_path D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/layers/SK_DEM.tif
k_param 2
lulc_path D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/SHP DATA FOR NITRA/Land 2000.tif
results_suffix
runoff_proxy_path D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/SHP DATA FOR NITRA/Rain.tif
subsurface_critical_length_n 0
subsurface_critical_length_p
subsurface_eff_n 0.5
subsurface_eff_p
threshold_flow_accumulation 1000
watersheds_path D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/case study area/case_all.shp
workspace_dir D:\PHD THESIS\ENV\Prof. Peter Mederly\FATEMEH\NDR

03/17/2022 20:45:16 natcap.invest.pygeoprocessing_0_3_3.geoprocessing WARNING
Items are not equal to 7 significant digits:
ACTUAL: 25.041801990317385
DESIRED: 25.04409115487313
03/17/2022 20:45:16 natcap.invest.pygeoprocessing_0_3_3.geoprocessing WARNING
Items are not equal to 7 significant digits:
ACTUAL: 25.041801990317385
DESIRED: 25.04409115487313
03/17/2022 20:45:18 natcap.invest.ndr.ndr INFO calculating flow accumulation
03/17/2022 20:45:24 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO flow_direction_inf 68.4% complete
03/17/2022 20:45:28 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO labeling flats
03/17/2022 20:45:28 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO draining away from higher
03/17/2022 20:45:28 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO draining towards lower
03/17/2022 20:45:28 natcap.invest.pygeoprocessing_0_3_3.routing DEBUG flats exist, calculating flow direction for them
03/17/2022 20:45:31 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO labeling flats
03/17/2022 20:45:31 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO draining away from higher
03/17/2022 20:45:32 natcap.invest.pygeoprocessing_0_3_3.routing.routing_core INFO draining towards lower
03/17/2022 20:45:32 natcap.invest.pygeoprocessing_0_3_3.routing INFO flats exist on second pass, must be flat areas that abut the raster edge
03/17/2022 20:45:33 natcap.invest.pygeoprocessing_0_3_3.routing DEBUG starting flow accumulation
03/17/2022 20:45:43 natcap.invest.ndr.ndr INFO Calculating slope
03/17/2022 20:45:46 natcap.invest.ndr.ndr INFO Thresholding slope
03/17/2022 20:45:48 natcap.invest.pygeoprocessing_0_3_3.geoprocessing WARNING
Items are not equal to 7 significant digits:
ACTUAL: 25.041801990317385
DESIRED: 25.04409115487313
03/17/2022 20:45:48 natcap.invest.ndr.ndr INFO Aligning rasters
03/17/2022 20:45:48 natcap.invest.pygeoprocessing_0_3_3.geoprocessing WARNING These two datasets might not be in the same projection. The different projections are:

‘filename: D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/layers/SK_DEM.tif’
PROJCS[“Krovak”,
GEOGCS[“GCS_Bessel 1841”,
DATUM[“D_unknown”,
SPHEROID[“bessel”,6377397.155,299.1528128]],
PRIMEM[“Greenwich”,0],
UNIT[“Degree”,0.017453292519943295]],
PROJECTION[“Krovak”],
PARAMETER[“latitude_of_center”,49.5],
PARAMETER[“longitude_of_center”,24.83333333333333],
PARAMETER[“azimuth”,0],
PARAMETER[“pseudo_standard_parallel_1”,0],
PARAMETER[“scale_factor”,0.9999],
PARAMETER[“false_easting”,0],
PARAMETER[“false_northing”,0],
UNIT[“Meter”,1]]

and:

‘filename:D:/PHD THESIS/ENV/Prof. Peter Mederly/FATEMEH/SHP DATA FOR NITRA/Land 2000.tif’
PROJCS[“WGS_1984_UTM_Zone_34N”,
GEOGCS[“WGS 84”,
DATUM[“WGS_1984”,
SPHEROID[“WGS 84”,6378137,298.257223563,
AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”,0],
UNIT[“degree”,0.0174532925199433],
AUTHORITY[“EPSG”,“4326”]],
PROJECTION[“Transverse_Mercator”],
PARAMETER[“latitude_of_origin”,0],
PARAMETER[“central_meridian”,21],
PARAMETER[“scale_factor”,0.9996],
PARAMETER[“false_easting”,500000],
PARAMETER[“false_northing”,0],
UNIT[“metre”,1,
AUTHORITY[“EPSG”,“9001”]],
AUTHORITY[“EPSG”,“32634”]]

03/17/2022 20:45:48 natcap.invest.pygeoprocessing_0_3_3.geoprocessing WARNING
Items are not equal to 7 significant digits:
ACTUAL: 25.041801990317385
DESIRED: 25.04409115487313
03/17/2022 20:45:53 natcap.invest.ndr.ndr INFO Aggregating runoff proxy to watersheds
03/17/2022 20:45:55 osgeo ERROR [errno 1] c:\users\public\documents\wondershare\creatortemp\tmps2lnol.tif, band 1: Failed to compute statistics, no valid pixels found in sampling.
03/17/2022 20:46:00 natcap.invest.ndr.ndr INFO Nromalizing runoff proxy
03/17/2022 20:46:02 natcap.invest.ndr.ndr INFO Classifying streams from flow accumulation raster
03/17/2022 20:46:03 natcap.invest.ndr.ndr INFO Mapping n load to LULC
03/17/2022 20:46:03 natcap.invest.ui.model ERROR Exception while executing <function execute at 0x0B87B8F0>
Traceback (most recent call last):
File “c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\ui\model.py”, line 1496, in _logged_target
File “c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\ndr\ndr.py”, line 389, in execute
File “c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\pygeoprocessing_0_3_3\geoprocessing.py”, line 2388, in vectorize_datasets
File “c:\users\natcap-servers\jenkins-home\workspace\natcap.invest\label\gce-windows-1\release_env\lib\site-packages\natcap\invest\ndr\ndr.py”, line 300, in map_load
KeyError: 5
03/17/2022 20:46:03 natcap.invest.ui.model INFO Execution finished
03/17/2022 20:46:03 natcap.invest.utils INFO Elapsed time: 49.04s

Hi @Fatemeh1,
I moved this to a new topic just to keep things organized.

I see you’re using InVEST version 3.4.0. That’s several years outdated and many bugs have been fixed since then. I strongly recommend upgrading to the latest version, 3.10.2.

KeyErrors usually happen when you have a value (in this case 5) in your raster that is missing from your biophysical table. Please see other threads about KeyErrors for more info. Let me know if you still have trouble!

3 Likes