SDR Model Question and Drainages Error

Hi all,

I’m working on setting up the SDR model for my study area and have a couple of questions. My site is located in the US, so I have the benefit of fairly good data availability for all of the necessary inputs, or ways of estimating them. For hydrographic data, I am relying on the National Hydrography Dataset (NHD) from the USGS. I have already compiled the necessary data and am at this point testing out the model to become more familiar with the outputs.

  1. I’m interested in running multiple landcover scenarios in different sub watersheds within a larger area of interest. While I am using the workbench for initial model test runs, I will be using the Python API in order to automate model runs. In the interest of speeding up run times, I am curious if it is possible to forgo some of the intermediate processing the model does. Specifically, calculating the flow accumulation, flow direction, and the stream rasters. These are provided as part of the NHD, with all of the preceding DEM processing steps already carried out, so they could be directly fed to the model.

I suspect the model’s code is set up such that avoiding these calculations is either not possible, or not trivial. Also, I’m not sure how significant the run time savings would be. When using three workers, my test runs so far have taken around ~37 s, which is not terrible, but ideally could be brought down a bit. Is there any way to avoid doing those calculations?

  1. Rather than relying on the model to calculate the stream network via the threshold flow accumulation value, I am considering passing the stream network to the model with the “drainages” input, and setting a high threshold value. However, when doing so, I receive an error message (logfile attached). Any idea what might be going on? Note: when I run the model with the exact same inputs, except for no drainages file and a lower threshold value, it runs without issue.

InVEST-natcap.invest.sdr.sdr-log-2023-02-21–10_23_31.txt (2.4 KB)


Hi @dg34,

SDR and all InVEST models are broken up into tasks that correspond to processing steps that produce files. We use the taskgraph library to manage dependencies between tasks and avoid recomputing intermediate steps when nothing has changed. If you run your multiple scenarios in the same workspace with the same DEM, those DEM processing steps should only run once. You can check the log file to see which steps are computed and which use cached results.

If you want to supply your own flow direction, flow accumulation, and streams, you’ll need to modify the source code and bypass those steps, which would be pretty straightforward.

However, when doing so, I receive an error message (logfile attached). Any idea what might be going on?

The error is ValueError: Could not open C:\Users\grafd\Documents\InVEST\workspace\trials\workbench\SDR\05\stream_05.tif as a gdal.OF_RASTER

GDAL could not open your streams raster. Most likely the path is wrong or the file is not a valid GTIFF.


Hi @esoth ,

Thanks for the quick response. Editing the source code seems pretty promising, even though I’m not the most well-versed in Python program development. Will I need to rebuild the natcap.invest python package after editing SDR? Or can I just go in and edit the source code? I already have installed natcap.invest into a Python environment via conda.

Regarding the error, it was due to using multiple workers. When I ran the model using synchronous execution, it ran without issue.


1 Like

Yes, you’ll need to rebuild the package after making changes to the code.

1 Like

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