Lecture 08 - Hands on with Ecosystem Services - Part 2

Reading: Polasky and Segerson 2009

Slides as Powerpoint: Download here

Video link: On Youtube

Content

Introduction to Sediment Retention Modeling

Opening the Discussion with Landscape Visualization

The lecture begins with a visually striking image that serves as more than just an aesthetic element. The image displays wiggly lines that represent the Mississippi River system, though initially some might mistake it for similar-looking rivers like those in Colombia. These two river systems share many characteristic features in their meandering patterns and sediment dynamics. If the view were expanded, the full extent from Louisiana to Minnesota would be visible, showing the complete watershed system. This particular visualization is a digital elevation model map, commonly referred to as a DEM, which plays a central role in understanding ecosystem services, particularly in the context of sediment retention modeling.

The sediment retention model fundamentally depends on various landscape factors, with slope being one of the most critical. The map displays raw elevation data, and slope represents the derivative of this elevation, providing crucial information about how water and sediment move across the landscape. The lecture’s agenda encompasses four main components that build upon each other systematically. First, there will be an exploration of the history of InVEST as a compelling example of how open science principles enable the development and spread of new ideas. Second, the technical details and underlying science of the sediment delivery model will be examined in detail. Third, participants will gain hands-on experience by actually running the model. Finally, the discussion will turn to the critical topic of valuation and how ecosystem services are quantified in economic terms.

The Evolution of InVEST as Open Science Software

From Proprietary Beginnings to Open Source Success

The journey of creating useful models for sustainability policy provides important lessons about the value of open science approaches. The Natural Capital Project’s experience with InVEST illustrates this evolution perfectly. While InVEST is now recognized as a user-friendly and well-documented tool, currently at version 3.16.4 as a stable release, its origins were far more humble and restrictive. The original InVEST version 1 existed merely as a collection of code saved to a CD-ROM in the early 2000s. The only remaining evidence of this early version is a lost photograph of someone holding that historic CD, highlighting how ephemeral code could be in that era before systematic version control and documentation practices became standard.

The second iteration of InVEST represented a significant step forward but still faced substantial limitations. InVEST version 2 was implemented as a toolbox within Esri’s ArcGIS program, which was and remains the industry standard for GIS applications. However, ArcGIS presents significant barriers despite its widespread use. The software is expensive and proprietary, creating access issues for many potential users. From a student’s perspective, perhaps the most significant problem is the loss of access after graduation when institutional licenses expire. This limitation motivated the adoption of QGIS for educational purposes, as it is free and has evolved to become superior to ArcGIS in many respects.

Technical and Access Challenges of the Toolbox Era

The toolbox approach of InVEST version 2 created numerous challenges that limited its impact and utility. Many partners, particularly those working in Sub-Saharan Africa, simply could not afford the expensive ArcGIS licenses required to run the tools. This economic barrier severely limited the reach and impact of the ecosystem services modeling approach in regions where it could have provided significant value. Beyond the access issues, there were substantial technical limitations. The development team lacked control over core code and algorithms, particularly for critical functions like hydrological routing. This dependency on external software limited the ability to optimize and improve model performance.

The Open Source Revolution with InVEST 3.0

The transformation to InVEST version 3.0 and subsequent versions marked a revolutionary change enabled by generous donor support. A dedicated software team was assembled to make the platform fully open source, fundamentally changing its accessibility and capabilities. InVEST 3.0 severed the dependency on ArcGIS, making it completely free to use. The codebase was rewritten in Python, with computationally intensive components implemented in C++ for optimal performance. Python proved to be an ideal choice because it can efficiently call fast C++ functions for demanding calculations, such as determining water flow paths across complex landscapes.

An unexpected but highly valuable benefit of this transition was the dramatic improvement in algorithm performance. The new algorithms, particularly those for hydrological routing, proved to be approximately ten times faster than their ArcGIS counterparts when calculating water flow paths. This performance improvement was not merely incremental but transformative, as it enabled calculations at a global scale that were previously computationally infeasible. The ability to process global datasets opened entirely new research possibilities and applications.

Modern Architecture and Automatic Documentation

InVEST has continued to evolve with sophisticated features that enhance both usability and transparency. The modern user interface is generated automatically from the underlying science code, ensuring perfect correspondence between what users see and what the code actually does. For example, when a Python snippet calls the NetCap InVEST urban cooling model and executes it, the user interface is generated directly from this function definition. This approach guarantees transparency and consistency. Power users can run the code thousands of times in batch mode, and they can be confident that the code matches exactly what they see in the interface. This architecture enables integration with Jupyter notebooks, cloud computation platforms, and high-performance computing clusters.

The automatic documentation system represents another crucial innovation. The comprehensive user guide is generated directly from the GitHub repository that documents the models. Well-written code, accompanied by clear explanatory text, automatically produces a user’s guide that is always current and accurate. Whenever a function is modified or improved, the documentation updates automatically without requiring manual intervention. This system eliminates the common problem of documentation lagging behind code development.

The Broader Impact of Open Science Principles

The transition to open science has proven important not just for running InVEST but for extending and adapting it to new applications. The GTAP InVEST model exemplifies this extensibility, leveraging InVEST’s comprehensive documentation and programmability to create tight integration with the Global Trade Analysis Project (GTAP) framework. This integration allows researchers to calculate economic impacts on the environment and dependencies on nature in ways that were previously impossible. This work culminated in a significant PNAS article that demonstrates the scientific value of these open approaches. All these advances were directly enabled by open science principles. If the code had remained locked within proprietary systems like MATLAB or ArcGIS, such extensions would have been nearly impossible to achieve. Good open science practices enable new science by allowing researchers to fork code, customize it for their specific needs, and contribute improvements back to the community.

Understanding the Science of Sediment Delivery

The Importance of Sediment in Agricultural and Water Systems

Sediment dynamics matter enormously to multiple stakeholders, particularly farmers who depend on soil conservation for long-term productivity. While soil scientists and hydrologists possess deep expertise in this field with numerous specialized models, the approach taken here focuses on consensus models that capture the essential dynamics while remaining interpretable and widely accepted. Experts in the field often concentrate on cutting-edge research and novel approaches, but for policy support applications, consensus models frequently prove more valuable because they are widely recognized, well-validated, and their results are interpretable by diverse stakeholders.

The model simplifies the complex science of sediment movement to focus specifically on overland sedimentation. This refers to sediment that has not yet reached streams or formed gullies but moves across the land surface during rainfall events. Plants and their associated root systems play a crucial role in this process by keeping soil deposited in place or maintaining its stability, thereby preventing it from entering reservoirs and other water bodies where it can cause significant problems.

The Universal Soil Loss Equation Framework

The consensus model employed is the Universal Soil Loss Equation (USLE), also known in its updated form as the Revised Universal Soil Loss Equation (RUSLE). This equation combines multiple biophysical factors through a multiplicative relationship: R, K, LS, C, and P. The ultimate goal is to calculate the tonnage per hectare per year of soil loss from each grid cell in the landscape, based on these variables which are estimated from extensive academic literature and field measurements.

The R factor represents rainfall erosivity, measured in the complex units of megajoules per millimeter hectare hour year. This factor indicates the potential of rainfall to cause erosion and is fundamentally a function of rain intensity. More intense rainfall events have greater erosive power and thus higher R values. The K factor represents soil erodibility, which captures the inherent susceptibility of different soil types to erosion. Different soils demonstrate markedly different resistance to erosive forces. For instance, granite-derived soils or heavy clay soils typically show greater resistance to erosion than sandy or silty soils.

Slope and Management Factors

The LS factor combines slope length and gradient into a single measure of topographic influence on erosion. This factor measures both the length of the slope and its steepness, recognizing that longer and steeper slopes are inherently more susceptible to erosion. Importantly, it is not simply the angle of the slope that matters but also the length over which water can accelerate and gain erosive power. The C factor captures the cover management effect, reflecting how different crops and management practices compare to a baseline condition, typically defined as bare, continuously tilled soil. Management practices such as maintaining cover crops, practicing conservation tillage, or establishing permanent vegetation can dramatically improve the C value and reduce erosion.

The P factor accounts for supporting practices, which relates to specific farming techniques and conservation measures. These include practices such as contour plowing, strip cropping, terracing, and other structural measures designed to reduce erosion. Each of these practices interrupts the flow of water and reduces its erosive power in different ways.

Data Requirements and Spatial Application

Understanding the data requirements for these models is crucial for successful application. The Natural Capital Project’s user’s guide provides extensive articles and detailed methods for generating or obtaining appropriate data for any location of interest. This documentation ensures that users can properly parameterize the model for their specific study areas.

The spatial application of these principles requires careful consideration of how water and sediment move across landscapes. Consider a simple landscape represented by four pixels with different land uses and a stream running through it. When elevation is added to this simple model, it becomes clear that when water falls on an upslope corn grid cell, it flows downhill according to topography, eventually reaching the stream. The USLE equation calculates the sediment leaving each grid cell, but the complete picture requires understanding what happens as sediment moves downhill toward the stream.

Sediment Routing and Retention Dynamics

The movement of sediment across the landscape follows predictable patterns based on topography and land cover. Arrows indicating sediment flow show that corn fields typically lose substantial amounts of soil, while forested areas retain more sediment but also contribute their own baseline erosion. This process continues iteratively downhill, with the model tracking precisely how much sediment from each grid cell ultimately reaches the stream. This computational approach allows the model to track not just sediment export but also the retention service provided by each pixel, which proves essential for estimating ecosystem service value.

This analysis must be repeated for every pixel in the landscape to build a complete picture. Interestingly, a forest grid cell located near a river, despite having lower inherent soil loss, may export more sediment to the stream than a corn field located further uphill. This counterintuitive result highlights how spatial arrangement fundamentally affects ecosystem service provision. Reforesting areas near streams provides particularly high ecosystem service value due to their strategic position in intercepting sediment before it reaches water bodies.

Digital Elevation Models and Flow Routing

The Foundation of Hydrological Modeling

Digital elevation models serve as the fundamental driver of sediment and water routing processes. These DEMs are produced through various sophisticated methods, including laser measurements from space shuttle missions that can measure elevation with remarkable precision. DEMs provide continuous raster data of elevation across landscapes, and from this elevation data, river networks and flow patterns become clearly visible and quantifiable.

From the raw elevation data in DEMs, it becomes possible to calculate flow direction, determining precisely where water will flow from each pixel based on topographic gradients. The flow direction can be represented visually with colors indicating the direction in degrees. The simplest and most commonly used algorithm for this calculation is D8 routing, which uses elevation differences to determine flow to the lowest adjacent pixel among the eight surrounding cells. This calculation of upslope contributing area and downslope flow path must be repeated for every pixel across the entire landscape to build a complete picture of hydrological connectivity.

Defining Stream Networks from Topography

The definition of what constitutes a stream in these models emerges from the DEM and flow accumulation calculations. Flow accumulation represents how many pixels contribute flow to any given pixel in the landscape. When sufficient water accumulates based on the upstream contributing area, that location is considered to represent a river or stream channel. Setting appropriate flow accumulation thresholds allows for precise definition of stream networks that match observed hydrological features.

Measuring Ecosystem Services in Sediment Retention

The best measurement of ecosystem service in the context of sediment retention depends critically on the perspective and needs of different stakeholders. Two key terms distinguish different aspects of the service: avoided erosion and avoided export. Avoided erosion measures how much soil loss is prevented by vegetative cover and management practices, which is particularly relevant to farmers concerned with maintaining soil productivity on their fields. Avoided export, on the other hand, measures how much sediment is kept out of reservoirs and water bodies, which is more relevant to downstream water users, water treatment facilities, and reservoir managers. The specific ecosystem service of interest depends entirely on the stakeholder perspective and the particular environmental or economic concern being addressed.

The Critical Role of Baseline Scenarios

The baseline scenario chosen for comparison fundamentally affects the valuation of ecosystem services. In the InVEST framework, retention is calculated by comparing current conditions to a bare soil baseline. This involves calculating how much sediment would be exported if the land were completely bare and unmanaged, then subtracting the actual export under current conditions. The choice of reference scenario greatly influences the calculated values and their interpretation, making it essential to be explicit and clear about what baseline is being used for comparison. Different baseline choices can lead to dramatically different ecosystem service valuations, even for the same landscape.

Hands-On Application with InVEST

Setting Up the Workspace and Model Parameters

The practical application begins with loading InVEST and QGIS for visualization and analysis. Users should set their workspace carefully in InVEST, using organized file structures such as those provided in the base data and InVEST sample data folders. When navigating to the SDR (Sediment Delivery Ratio) model, it is important to create a dedicated output folder to separate calculated results from input data. This output folder should be selected as the workspace to ensure all results are properly organized.

The file suffix option provides a useful way to organize outputs when running multiple scenarios. For instance, when analyzing different years such as 2025, 2030, and 2035, suffixes can be appended to output files to distinguish between scenarios. While this approach works, creating separate folders for each scenario often provides better organization for complex analyses.

Configuring the Five Essential Inputs

The model requires five essential inputs that must be properly configured. First, the DEM file (such as DEMGura.tiff) provides the topographic foundation. Second, the erosivity layer captures rainfall patterns and intensity. Third, the erodibility layer represents soil characteristics. Fourth, the land use map (such as landusegura.tiff) defines the spatial distribution of different land cover types. Fifth, the biophysical table (such as Biophysical Table Gura.csv) contains the C and P factors for each land use type. Each input must be properly loaded and verified, with checkmarks appearing to confirm successful configuration.

Visualization in QGIS

After configuring InVEST, the DEM should be added to QGIS for visualization. The color scheme should be adjusted to single-band pseudocolor to properly display floating-point elevation values. In the example landscape, elevations range from 1,600 meters at the lowest points to 3,100 meters at the highest peaks. Applying an appropriate color ramp helps visualize the topographic variation. Zooming in reveals the intricate river network carved into the landscape. The visualization can be enhanced by stretching the color bar using “Stretch Using Current Extent” or by manually adjusting the range to highlight specific elevation bands of interest.

Adding the watershed boundary (such as watershedgura.shp) as a vector file provides important context. The symbology should be changed to a blue outline for visibility against the elevation background. Vector files represent geographic features as lines or polygons defined by latitude-longitude coordinate pairs, in contrast to the raster format of the DEM.

Understanding Watershed Definitions

A watershed encompasses all locations that contribute flow to a specific outlet point, typically at the downstream end of a river system. Sub-watersheds represent smaller drainage areas within the larger watershed, defined by flow to intermediate points along the stream network. Hydrologists routinely track water quality and quantity statistics at the sub-watershed level, making these units fundamental for water resource management and analysis.

Running the Model and Interpreting Results

With all inputs configured, the remaining coefficients should be entered using appropriate values from the user’s guide or literature. The threshold flow parameter, typically set to 1,000, defines the stream network as those pixels with at least 1,000 upstream pixels contributing flow. Once all parameters are set, the model can be executed. Processing may take several seconds to minutes depending on the size of the study area and computer performance. If errors occur, careful checking of inputs and examination of the log file usually reveals the issue.

Analyzing Model Outputs

After successful execution, the SDR output folder contains multiple result files. The sediment export map (sedimentexport.tiff) should be added to QGIS first. Adjusting the color bar to quantile mode provides better visualization by dividing the data into classes with equal numbers of pixels, making the display robust to outliers. The sediment export map reveals spatial patterns, with pixels near streams typically showing higher export values. Both land cover type and proximity to the river significantly affect sediment export rates.

The avoided export map (avoidedexport.tiff) represents the actual ecosystem service provision. Using a green color ramp for retention values and continuous mode visualization helps identify high-value pixels. These pixels perform significant work in retaining soil, especially when compared to the bare soil baseline. Further adjustments to the color ramp and maximum values can enhance visualization of spatial patterns.

Key Insights from Spatial Analysis

The analysis reveals that pixels near streams provide particularly high retention value, supporting policies such as riparian buffer requirements that mandate vegetation maintenance near water bodies. The path of water flow also proves critical, with areas of high flow accumulation being particularly important for retention services. The river channel begins where flow accumulation crosses the defined threshold, marking the transition from overland to channel flow processes.

Additional outputs include sediment deposition maps and avoided erosion calculations, each providing different perspectives on ecosystem service provision. While QGIS and simple screen capture tools prove useful for sharing and annotating maps during analysis, Python should be used for producing publication-quality figures for papers and reports.

Automation and Advanced Applications

Transitioning to Scripted Workflows

The power of InVEST extends beyond the graphical interface to support automated and scripted workflows. Instead of repeatedly using the interface for multiple runs, users can save their configuration as a Python script. Within InVEST, the “Save As” function allows export as a Python script, creating a file such as executeinvestSDR.py that captures all settings and parameters.

Opening this script in a code editor like VS Code reveals that the desktop application has generated a complete Python script replicating the calculation with all parameter values preserved. This script provides the foundation for batch processing, sensitivity analysis, and integration with larger modeling workflows. The next phase of work involves using Python to run models in a fully scripted environment, enabling more sophisticated analyses and automation of complex modeling tasks.

The Path Forward

The comprehensive understanding of sediment retention modeling gained through this hands-on experience provides the foundation for more advanced applications. The combination of theoretical understanding, practical application, and scripting capabilities enables researchers and practitioners to apply these tools effectively for ecosystem service assessment and landscape management planning. The open science approach of InVEST ensures that these capabilities continue to expand and improve through community contributions and collaborative development.

Transcript

All right, let’s get started. Welcome to Lecture 8: Hands-On with Ecosystem Services Part 2. First, following today’s theme, who knows what this is? Besides being a visually striking image, what do you think it depicts? What are these wiggly lines? Does anyone know where this is? Columbia? No, but that’s a similar-looking river. This is the Mississippi. The two rivers share many characteristics. If I zoomed out, you’d see Louisiana and Minnesota. This is a digital elevation model map (DEM), which will be central to our discussion on ecosystem services, specifically the sediment retention model.

The sediment retention model depends on factors like landscape slope. This map shows raw elevation; slope is the derivative of elevation. We’ll dive into these concepts. The agenda is: first, a history of Invest as an example of how open science enables new ideas; then, the details and science of the sediment delivery model; then we’ll run it; and finally, discuss valuation.

Any questions or logistical notes? If you have issues with the problem set, let me know. Feel free to reach out.

Let’s dive into the agenda. How do we make useful models for sustainability policy? I’ll share a story about open science software at the Natural Capital Project. We’ve been using Invest, which is now user-friendly and well-documented, but it wasn’t always that way. We’re on Invest version 3.16.4, a stable version. The original Invest version 1 was a collection of code saved to a CD-ROM in the early 2000s. The only remaining evidence is a lost photo of someone holding that CD.

Back then, code was ephemeral. Invest version 2 was coded as a toolbox within Esri’s ArcGIS program. Who here has used ArcGIS? It’s the standard GIS tool, but expensive and proprietary. From a student’s perspective, the biggest problem is losing access after graduation. That’s why we use QGIS, which is free and, in many ways, now superior.

In Invest’s history, the toolbox approach had challenges. Many partners, especially in Sub-Saharan Africa, couldn’t afford it. Technically, we lacked control over code and algorithms, such as hydrological routing. This changed with Invest version 3.0 and onwards, thanks to generous donors. A dedicated software team made it fully open source. Invest 3.0 disconnected from ArcGIS, making it free. It was written in Python, with computationally intensive parts in C++. Python is useful because it can call fast C++ functions, like calculating water flow paths.

A surprise benefit was that our new algorithms, such as for hydrological routing, were much faster than ArcGIS—ten times faster at calculating water flow paths. This allowed calculations at a global scale.

Invest has continued to evolve. The modern user interface is generated automatically from underlying science code. For example, a Python snippet calls the NetCap Invest urban cooling model and executes it. The user interface is generated from this function, ensuring transparency. Power users can run the code thousands of times, and the code matches the interface. This enables Jupyter notebook access, cloud computation, and high-performance computing.

Automatic documentation is crucial. The user guide is generated from the GitHub repository documenting the models. Good code, accompanied by explanatory text, creates a user’s guide that is always up to date. If you change a function, the documentation updates automatically.

Why is this transition to open science important? It enabled us to not just run Invest, but extend it. For example, the GTAP Invest model leverages Invest’s documentation and programmability to connect tightly with GTAP, allowing us to calculate economic impacts on the environment and dependencies on nature. This led to a PNAS article we’ll read later. All these steps were enabled by open science. If the code were in MATLAB or ArcGIS, this would be nearly impossible. Good open science enables new science: you can fork the code, make it your own, and contribute back to the community.

Any questions on open science before we move to our second model, the sediment delivery model?

Sediment matters a lot, especially to farmers. Soil scientists and hydrologists have deep expertise, but we’ll summarize it into a consensus model. Experts often focus on cutting-edge research, but for policy support, consensus models are often preferable—they’re widely recognized and interpretable.

We’ll simplify the science and focus on overland sedimentation—sediment that hasn’t reached the stream or formed gullies, but moves overland. Plants and their root systems can keep soil deposited or stable, preventing it from entering reservoirs.

The consensus model is the Universal Soil Loss Equation (USLE), also known as the Revised Universal Soil Loss Equation (RUSLE). It combines biophysical factors: R, K, LS, C, and P. The goal is to calculate the tonnage per hectare per year of soil loss from a grid cell, based on these variables, which are estimated from academic literature.

R is rainfall erosivity, measured in megajoules per millimeter hectare hour year, indicating the potential of rainfall to cause erosion. It’s a function of rain intensity.

K is erodibility, the susceptibility of soil to erosion. Different soils withstand erosive forces differently—granite or clay soils are more resistant.

LS is the slope length-gradient factor, measuring slope length and steepness. Longer and steeper slopes are more susceptible to erosion. It’s not just slope; the length matters too.

C is the cover management factor, reflecting the effect of crops and management practices compared to a baseline, such as bare, continuously tilled soil. Practices like cover crops improve the C value.

P is the supporting practices factor, related to farming techniques like plowing, strip cropping, and terracing.

Understanding the data is important. The Natural Capital Project’s user’s guide provides articles and methods for generating data for your location.

Now, let’s talk about spatial application. We’ve seen land use/land cover maps. Here’s a simple one with four pixels and a stream. We’ll add elevation, so when water drops on a corn grid cell, it flows downhill, eventually reaching the stream.

The USLE equation calculates sediment leaving a grid cell. But we also need to consider what happens as sediment moves downhill toward the stream. The arrows indicate sediment flow: corn loses a lot, forest retains some, but also contributes its own sediment. This process continues iteratively downhill, tracking how much sediment reaches the stream from each grid cell.

This computation lets us track not just export, but retention by each pixel, which is useful for estimating ecosystem service value.

We’ll repeat this for each pixel. For example, the forest grid cell near the river, despite lower soil loss, exports more sediment to the stream than the corn cell further uphill. Spatial arrangement matters: reforesting near the stream has high ecosystem service value.

Combining the soil loss equation with a simplified routing algorithm, we calculate the sediment delivery ratio, which is then scaled up to larger landscapes.

The digital elevation model (DEM) drives this process. DEMs are produced by methods like lasers from the space shuttle, which measure elevation precisely. DEMs provide continuous raster data of elevation, revealing river networks.

From DEMs, we can calculate flow direction—where water will flow from each pixel. The color indicates flow direction in degrees. The simplest algorithm, D8 routing, uses elevation to determine flow to the lowest adjacent pixel. We calculate upslope and downslope for every pixel, repeating the calculation across the landscape.

What is a stream? In this model, streams are defined from the DEM and flow accumulation—how many pixels flow into a given pixel. When enough water accumulates, it’s considered a river. Setting flow accumulation thresholds defines streams precisely.

Now, let’s consider the best measurement of ecosystem service in this context. Two terms: avoided erosion and avoided export. Avoided erosion measures how much soil loss is prevented by cover, relevant to farmers. Avoided export measures how much sediment is kept out of reservoirs, relevant to downstream water users. Ecosystem service depends on the perspective.

The baseline scenario affects valuation. In INVEST, retention is calculated by comparing to bare soil—how much would be exported if the land were bare, minus actual export. The reference scenario greatly influences values, so it’s important to be clear about the baseline.

That’s the SDR model. Any questions before we dive into Invest?

Now you are all soil experts. NetGap focuses on useful tools, not irrelevant details. Go ahead and load up Invest and QGIS.

Set your workspace in Invest, using the organized files in your base data, invest sample data. Scroll to the SDR model and create an output folder to separate calculated results from inputs. Select this output folder as your workspace.

For file suffix, you can run multiple scenarios (e.g., years 2025, 2030, 2035) and append suffixes to outputs. It’s a way to organize outputs, though separate folders are better.

Set the five inputs: DEM (DEMGura.tiff), erosivity, erodibility, land use (landusegura.tiff), and the biophysical table (Biophysical Table Gura.csv). Ensure you get checkmarks for each input.

Next, add the DEM to QGIS. Adjust the color scheme to single-band pseudocolor for floating point elevation values. The lowest elevation is 1,600 meters, highest is 3,100 meters. Apply the color ramp.

Zoom in to see the river network. You can stretch the color bar using “Stretch Using Current Extent” or manually adjust the range for better visualization.

Add the watershedgura.shp vector file to QGIS. Change the symbology to outline blue for visibility. Vectors represent lines or polygons defined by latitude-longitude points.

The definition of a watershed is all locations that flow into a specific point, such as the end of a river. Sub-watersheds are subsets, defined by flow to intermediate points. Hydrologists track statistics at the sub-watershed level.

We’re almost ready to run the model. Enter the remaining coefficients using default values from the user’s guide. Threshold flow is 1,000, defining the river network as pixels with at least 1,000 upstream pixels.

Once all inputs are entered, hit run. The model may take a few seconds. If you encounter errors, check your inputs and logging level.

Open your workspace and look at the SDR/output folder. Start with sedimentexport.tiff. Add it to QGIS and adjust the color bar to quantile mode for better visualization. Quantile mode divides the data into classes with equal pixel counts, making it robust to outliers.

Analyze the sediment export map: red values are low export, green and blue are higher. Spatially, pixels near the stream contribute more export. Land cover and proximity to the river affect sediment export.

Next, add avoidedexport.tiff, representing ecosystem service. Adjust the color bar to green for retention. Use continuous mode, zoom in to see high-value pixels. These pixels are doing significant work retaining soil, especially compared to the bare soil baseline.

You can further adjust the color ramp and maximum value for better visualization. The key takeaway is that pixels near the stream are highly valuable for retention. Policies like riparian buffers require vegetation near streams to maximize ecosystem service.

The path of water flow also matters; areas with high flow accumulation are important for retention. The river starts where flow accumulation crosses the threshold.

Other outputs include sediment deposition and avoided erosion, depending on the perspective.

When producing maps for papers, use Python for final figures, but QGIS and the snipping tool are useful for sharing and annotating maps.

The definition of a watershed is all locations flowing to a point. Sub-watersheds are subsets, forming a tree-like structure. Hydrologists track water statistics at these levels.

We’re ready to run the model as power users. Instead of using the interface repeatedly, you can save your setup as a Python script. In Invest, click Save As and select Python script. Save it as executeinvestSDR.py.

Open the script in VS Code. The desktop application generates a Python script that replicates your calculation, including all parameter values. Next time, we’ll use Python to run this in a scripting environment.