This forum is shutting down! Please post new discussions at


Hi! I have a question about SDR model. Anyone who can answer this for me?

I've already run the SDR model almost 10 times, but every time there's an error like this:

12/04/2017 22:18:43  natcap.invest.sdr  INFO     calculate ic
12/04/2017 22:18:44  natcap.invest.sdr  INFO     calculate sdr
12/04/2017 22:18:44  natcap.invest.sdr  INFO     calculate sed export
12/04/2017 22:18:45  natcap.invest.sdr  INFO     calculate sediment retention index
12/04/2017 22:18:46  natcap.invest.sdr  INFO     calculate sediment retention
12/04/2017 22:18:46  natcap.invest.sdr  INFO     calculate S factor
12/04/2017 22:18:47  natcap.invest.sdr  INFO     calculating d_dn bare soil
12/04/2017 22:18:53  pygeoprocessing.routing.routing_core INFO     visit_stack on stream distance size: 334526 
12/04/2017 22:18:59  pygeoprocessing.routing.routing_core INFO     visit_stack on stream distance size: 191602 
12/04/2017 22:19:05  pygeoprocessing.routing.routing_core INFO     visit_stack on stream distance size: 28425 
12/04/2017 22:19:06  natcap.invest.sdr  INFO     calculating d_up bare soil
12/04/2017 22:19:06  natcap.invest.sdr  INFO     calculate ic
12/04/2017 22:19:09  natcap.invest.sdr  INFO     generating report
12/04/2017 22:19:11  root               ERROR    ---------------------------------------------------
12/04/2017 22:19:11  root               ERROR    ---------------------- ERROR ----------------------
12/04/2017 22:19:11  root               ERROR    ---------------------------------------------------
12/04/2017 22:19:11  root               ERROR    Error: exception found while running natcap.invest.sdr
12/04/2017 22:19:11  root               DEBUG    
12/04/2017 22:19:11  root               DEBUG    Build details
12/04/2017 22:19:11  root               DEBUG    Interpreter
12/04/2017 22:19:11  root               DEBUG    Current temp dir: D:\document\sedimentation_workspace\tmp
12/04/2017 22:19:11  root               DEBUG    tempfile.tempdir: D:\document\sedimentation_workspace\tmp
12/04/2017 22:19:11  root               DEBUG    
12/04/2017 22:19:11  root               DEBUG    System
12/04/2017 22:19:11  root               DEBUG    OS              : Windows-8-6.2.9200
12/04/2017 22:19:11  root               DEBUG    Processor architecture: AMD64
12/04/2017 22:19:11  root               DEBUG    FS encoding     : mbcs
12/04/2017 22:19:11  root               DEBUG    Preferred encoding: cp1252
12/04/2017 22:19:11  root               DEBUG    
12/04/2017 22:19:11  root               DEBUG    Python
12/04/2017 22:19:11  root               DEBUG    Version         : 2.7.9
12/04/2017 22:19:11  root               DEBUG    Build           : ('default', 'Dec 10 2014 12:24:55')
12/04/2017 22:19:11  root               DEBUG    Compiler        : MSC v.1500 32 bit (Intel)
12/04/2017 22:19:11  root               DEBUG    Implementation  : CPython
12/04/2017 22:19:11  root               DEBUG    Architecture    : 32bit
12/04/2017 22:19:11  root               DEBUG    Linkage format  : WindowsPE
12/04/2017 22:19:11  root               DEBUG    
12/04/2017 22:19:11  root               DEBUG    Packages
12/04/2017 22:19:11  root               DEBUG    Cython          : ?
12/04/2017 22:19:11  root               DEBUG    Numpy           : 1.11.2
12/04/2017 22:19:11  root               DEBUG    Scipy           : 0.16.1
12/04/2017 22:19:11  root               DEBUG    OSGEO           : 1.11.3
12/04/2017 22:19:11  root               DEBUG    Shapely         : 1.5.5
12/04/2017 22:19:11  root               DEBUG    InVEST          : 3.3.3
12/04/2017 22:19:11  root               DEBUG    
12/04/2017 22:19:11  root               DEBUG    
12/04/2017 22:19:11  root               DEBUG    Exception not environment-related
12/04/2017 22:19:11  root               DEBUG    Printing traceback
Traceback (most recent call last):
  File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.iui.executor", line 620, in runModel
  File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.sdr", line 297, in execute
  File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\natcap.invest.sdr", line 936, in _generate_report
  File "C:\Users\natcap-servers\jenkins-home\workspace\natcap.invest\label\GCE-windows-1\exe\build\invest\out00-PYZ.pyz\pygeoprocessing.geoprocessing", line 944, in aggregate_raster_values_uri
KeyError: 0

I checked rasters resolution which all 30 m *30 m, filled DEM sinks, all rasters have the same boundary clipped from watershed shapefile except DEM raster which is extending beyond the watersheds of interest. However, the watershed's boundary isn't exactly the same as rasters (K, R, LULC), I suppose this is because the watershed file is a shapefile with smoother boundary (like what the attach shows). 

Is this the problem why the error comes up? If not, could anyone point the reason for me?




  • RichRich Administrator, NatCap Staff
    Hi, I've seen that error many times before. It happens on the final report generation stage of SDR and might be related to the values in 'ws_id' in the watershed shapefile. Can you make sure non of those values are NULL or blank? If they look okay, would you be willing to try this more recent version of InVEST and make sure it's not a bug we patched  long time ago?

  • @Rich Thank you for your reply!

    I just saw the latest version of InVEST and I'm downloading it right now.

    I only have one polygon in the watershed polygon, and the 'we_id' is 0. I think this's not the problem. I will try the newly released model. 

    One more question, I need to enter the watershed shapefile, not the subwatershed shapefile into the model, right?
  • Hi @Rich,

    I tested on the new version, unfortunately, it still doesn't work. Meanwhile, I saw the log said no flow direction found when it routing. Do I need to use flow direction tool in ArcGIS to fix this?
    1312 x 832 - 95K
    1298 x 195 - 22K
  • RichRich Administrator, NatCap Staff
    It might need a pitfill, but happy to take a look if you want to Dropbox me your datastack to (p.s. you can create a single file datastack by going to the file menu in invest and "save datastack" or similar. You can choose a datastack archive, not a parameter file, and Dropbox me that if you like)
  • swolnyswolny Member, NatCap Staff
    Regarding providing the watershed vs sub-watershed shapefile to the model. You can give SDR either the watershed or sub-watersheds, depending on what spatial unit you're interested in getting results for. The model only uses them to aggregate sediment load and export, providing a shapefile with the total load/export for each watershed or sub-watershed. Whether you provide watersheds or sub-watersheds, the shapefile still must have a "ws_id" field with unique integer values for each polygon.

    ~ Stacie
  • RichRich Administrator, NatCap Staff
    Hi @Sara_Han, I know you said the "ws_id" field for your watershed was 0, but when I look at it, it's a null value. (this is the "watersheds.shp" file you sent). I replaced the null field with 0 and was able to run SDR on my end. Can you try replacing it as a 0 on your end and trying it too? 
  • @Rich  
    I didn't receive an email notice that you already replied me, and I didn't come here to check either. 

    I changed the ws_id field to 0, and finally, it works!!!!! 
    Thank you soooo much!
Sign In or Register to comment.