 Hello, I'm Stacey. I'm a GIS analyst with a natural capital project, and I'm glad that you've joined me to learn some techniques for working with the geospatial data that's used by the Invest Ecosystem Service Modeling Toolkit. In this episode, we'll see what goes into creating a good stream network from a digital elevation model. To get the most out of this tutorial, I highly recommend following along in your own GIS session. In this video, we will demonstrate techniques in QGIS, and we'll be working with some sample data, which is linked to on the webpage for this video. Also in this episode, we'll be using one of the Invest Tools, so make sure that Invest is installed. In several previous episodes, including preparing the DEM, we worked with data in Nepal, so we will continue with that location in this video. If you happen to have a QGIS session saved from those earlier episodes in Nepal, you can use it again now. That's totally fine too, just open up a new session. So if you haven't already, now is a good time to pause this video, download the sample data, unzip it, and bring up a QGIS session before continuing. There's three invest models that make use of a stream network. The sediment model, SDR, nutrient model, NDR, and seasonal water yield. The way these models work, nutrient, sediment, or precipitation runs off of a pixel on the landscape, and it moves down slope until either it is retained by the landscape, or it reaches a stream. Once it hits a stream, the model stops calculating, since these models do not include in stream processes. Because the model stops calculating at streams, it's very important that the model creates a stream network that represents the real world, at least reasonably, accurately. It is also important for creating the watershed that you'll use for your study area, which is a topic that we'll cover in a future tutorial. Streams are derived from the digital elevation model, or DEM, that you provide as input, along with another model input called the threshold flow accumulation, or TFA. The TFA value represents the number of upslope pixels that must flow into a particular pixel in order for it to be considered part of a stream. Another way of thinking about this is that it defines the upslope contributing area that is needed for a stream to form. In the images to the right, you can see the difference between a large TFA value of 10,000 pixels and a small TFA value of 100 pixels. A large TFA value will produce a coarse stream network with fewer tributaries, like we see in the top image. A small TFA value will produce a stream network with more tributaries, like we see in the lower image. Now, thinking about how the models work, each of these options will produce very different results. In the top map, the yellow pixel is far away from the stream. So there is potentially a lot of vegetation between the pixel and the stream that might retain sediment or nutrient, so it's likely that less erosion or nutrient originating from that pixel will make it to the stream. But in the bottom map, that same pixel is now much closer to the stream, so it's much more likely that sediment or nutrient from that pixel will enter the stream as export. So then a common question is, what is the correct threshold flow accumulation value to use for my project? The correct TFA value is the value that causes the model to create a simulated stream network that is as close as possible to the real-world stream network in the place that you're studying. So this is going to be different in each case. To determine this, you will need a real-world stream map of some sort, preferably geospatial, because then it's easy to visually compare with the modeled streams. If you only have one that isn't geospatial, that's helpful too. It's just not as easy to directly compare them. You can also make use of satellite data or other GIS basemaps. Now an important thing to accept is that modeled stream networks are pretty much never exactly the same as the real-world. If you try to choose the DEM and the TFA values to create as good of a network as possible, it will not be exactly the same. And it's likely that you'll need to do multiple iterations of creating streams until you find the best TFA value for your needs. Here's an example of this from an analysis in Bolivia. The first DEM that I tried was from Aster, which I've used in other projects successfully. If you compare the Aster map in the upper left to the national streaming layer in the lower right, you'll see that they don't match very well. So next, I tried an SRTM DEM, which is another globally available data set. And it seemed even more inaccurate compared with the real-world stream network. So finally, I tried a HydroSheds DEM. And while it isn't perfect, it came much closer to matching the real-world streams than the others. And that's the one we decided to use for hydrology modeling. Interestingly, I have tried HydroSheds in other locations for other projects, and it did not work very well, and we did not end up using it. But this time it was the best one, which illustrates the point that you might need to try multiple DEMs to find the one that works best in the particular place you're modeling. One other thing of note here is that it is really, really hard for any model to create a stream network in a very flat place. Because models rely on elevation change to know where water flows from one pixel to the next. But if there is no elevation change between pixels, the model just doesn't know where to route water. In Bolivia is actually a very large, very flat wetland, which makes it even more difficult to create a stream network that matches the real world. And in reality, streams don't tend to stay the same in floodplains and wetlands anyway. So this is just something to keep in mind if you're working in a very flat landscape. So how to create streams? Of course, the hydrology models themselves will create a stream layer, and you're welcome to just do iterations of the model to determine the correct stream network. However, it can take a while to run a model, especially if we need to do multiple iterations just to look at the streams. So personally, I find it to be faster and more efficient to do this step outside of the model. It is also certainly possible to create a stream layer manually using tools in QGIS. But since we're using invest, it's even easier to use a tool that we provide called RouteDEM. RouteDEM was created to do the DEM and stream processing outside of the model, which makes it faster and more efficient to evaluate how your streams will look and invest, without having the additional overhead of running the whole freshwater model over and over. And by using RouteDEM, you'll also know that you're creating exactly the same stream network as the invest freshwater models, which may not be the case if you make streams using QGIS tools. Okay, that's enough theory. Let's go to our GIS session. Starting in our file explorer, let's bring in the DEM that we'll use to create streams. If you are using the same GIS session from the preparing the DEM tutorial, you'll probably already have the prepared DEM added to the map. So just hang out a minute. If you're starting with a new session, go to the sample data folder, which is called creating streams data. And inside of here, there's a file called DEM underscore filled.tif. Let's bring it into the GIS. This is Aster DEM data for our study area in Nepal. In the previous tutorial, we mosaic to the raw data tiles together, we re-projected them to a UTM projected coordinate system, and we filled sinks. The next step in the process is to see what the stream network looks like, which we'll create with route down. So let's launch the route DEM tool. I'm using Windows, so I will do that through my start menu. And if you're on Mac, you can launch it in the same way that you do other invest models. We'll just go to the invest folder and scroll down to route DEM and launch it. And note that your version of invest may be different than mine, since we are not updating these videos every time invest updates. But hopefully route DEM will be the same or similar enough to follow along. The first input is the workspace where the output files will be written. So let's navigate to wherever it is that you want to keep them. And we'll create a folder called route DEM underscore output. And we will select that folder as our workspace. For result suffix, I like to include the threshold flow accumulation value that I'm using for this run. We'll talk about this in a moment, but we'll start with a TFA value of 1000. So for the result suffix, enter the string TFA 1000. For the digital elevation model, we want to drag in the file DEM underscore filled dot TIF from the sample data folder. And this raster only has one band. So we will type a one in for the band index. In this case, we will not calculate slope. So leave that box unchecked. For the routing algorithm route DEM provides two choices, D8 and MFD or multiple flow direction. Each of these will produce stream networks that look rather different. D8 is more simplistic. And it assumes that all water running off of a pixel goes into a single downslope pixel that is in one of the eight cardinal directions. MFD is used to create streams that are thin lines, which is more like what you expect from a stream network. MFD is thought to be more accurate, since it simulates water moving in multiple directions from a single pixel. But some of the streams that it creates can be much wider, more like floodplains. So there are tradeoffs to each one. This is the algorithm that the invest freshwater models currently use. So we will select that. Now we need to calculate flow direction and flow accumulation before streams can be created. So make sure there are check marks next to all of the boxes for calculate flow direction, calculate flow accumulation, and calculate stream thresholds. Once we click calculate stream thresholds, now we need to enter a threshold flow accumulation limit. Again, that value defines the number of upslope pixels that must flow into a particular pixel for it to be considered part of the stream. I generally recommend starting with a value of 1000, although that's a fairly arbitrary number. Anyway, the value that you end up using will depend on the size of your pixels and landscape characteristics, and you'll probably need to try several TFA values before you find the one that makes a stream network that comes close to the real world. So for now, let's enter a value of 1000. And we will not calculate distance to stream. So leave that box unchecked. Anytime that we're doing hydrologic modeling, it can take a while to do the DEM processing, because it is computationally intensive. For this example data, it might take a few minutes for the tool to run, and it will be different on different computers. So feel free to pause this video until it's finished. When it's finished. Click the open workspace button. And in here you should see the flow direction, the flow accumulation, and the stream layers, the route DEM created, along with the log file. Let's bring the stream layer into the GIS. It's called stream mask TFA 1000.tif. Now, when we first look at this map with the stream zoomed out, they look like they're very disconnected and very choppy. But once we zoom in, we can actually see that they are continuous. But if your stream network is not continuous, but it is all chopped up when you zoomed in, that usually means that the DEM has errors that were not fixed by filling sinks the first time. So you can try filling sinks again, but if the streams are still not continuous, that probably means that you need to try a different DEM. If we move around the map, we can see how the MFD algorithm does create some very wide streams. And in general, this is okay, but sometimes it can cause problems if you are modeling riparian buffers in your land cover map, or something similar that is based on the stream network, if the streams are not actually that wide in real life. So this is an issue that we are aware of, but we still haven't resolved in the models. If this turns out to be an issue for your modeling, one option is to try burning narrow streams into your DEM, and we won't get into stream burning here, and it can be a tricky thing to do. But know that it's an option, and you can look for more information about it online. Okay, now let's see how this stream network compares with a river layer for Nepal that was created by Isimod from National Topographic Survey Maps. Let's go back to the sample data folder in our file explorer. And we have a folder called Nepal underscore rivers. Inside of here, there's a shapefile, and there's metadata. Let's go from river.shp into the GIS. I'm going to change the symbology a little so that it is easier to see. Well, in this case, we're pretty lucky. The stream network created by the DEM with a threshold flow accumulation value of 1000 actually follows the real world stream network pretty closely. It's exactly the same, but they're not bad at all. I'd be happy to use this DEM for an analysis. And we actually did use it for our project in this area. But one thing to notice is that the modeled streams often have more tributaries than the national stream layer. In order to improve this, the next step is to rerun route DEM with a larger threshold flow accumulation value, maybe 2000 or 5000 and see how the result compares. I always need to do several iterations of refining the TFA value before I settle on one that creates a stream network that looks good enough. And again, if the modeled stream network looks bad, no matter what you do, try a different DEM. So this will be your homework. Rerun route DEM with different TFA values until you find one that comes pretty close to a national stream layer. If we were using this for an actual project, we would then use that same TFA value as input to whatever hydrology models were running. Okay, that's enough for this session. Now that the DEM is prepared, and we've determined that it makes acceptable streams, the final step will be delineating the watershed that is your modeling area of interest, and we will cover this in another episode. If you have any questions or comments about this episode, we'd love to hear from you on our community forum. We look forward to the forum in this video's webpage where you can search for previous posts and create a new post under the category of training. I and other techies at NACAP will see your post and we'll respond as soon as we can. Thanks for following along.