[MUSIC] Hello again and welcome back. In this lecture, we're going to go over how we make streamlines out of a digital elevation model. And we're doing this for a couple of reasons, one is that you've all ready done it in a few of your assignments, so you did it in a previous class as an introduction to complex processing algorithms that require multiple steps. And you did it in this class, as your model builder tutorial, and I want to talk to you a bit, conceptually, about what we're doing at each stage, to kind of demystify some of this as well. I know that many of you aren't that interested in hydrologic processing. It might not be specific to your area of work, but I still think that clarifying what we did when we worked on this is going to be helpful. So in this lecture I'm going to go over it all conceptually, and in the next lecture will actually go through tool by tool. So first off, we have a series of steps to find the locations that have higher flows. So, in the past you used flow direction, and flow accumulation, and some thresholding tools to find streamslines based upon a digital elevation model. And these tools are specific to the hydrologic domain, and we chain them together in order to make the algorithm, the process, that we need in order to get the actual streamlines out of it. Each of these tools in isolation only gets us some specific piece of information, but together in order we get what we need. And the last thing I want to point out here is that when we look at a digital elevation model like this, we can easily see the streams in the landscape. You probably see it even if you don't work with rivers and water all the time. These low spots, these dendritic networks are sort of obvious to most of us, and not all landscapes look like this, but it's very clear where the water flows. The water flows down here into here and then down along here, but how do you tell a computer what that looks like? That's the problem we're dealing with. So conceptually, just kind of before we really dig into it, just remember that as water flows it can erode the landscape, that's how this dendritic networks form. They don't just start dendritic in the mountains, that water slowly carries away the sediment and creates that network of merging streams that we're used to. So even though it says here that topography defines the drainage direction, similarly, the drainage defines the topography. And while you have some initial set of starting conditions to do the geology, everything is kind of chaotic, and changes together. So as the weather sculpts the terrain, the terrain continues to move and changes the water flow too. So let's start with Pit Removal. With a digital elevation model we aren't getting an accurate representation for the landscape, remember we have a model of it. And that in creating a DEM at 30 meters, or 10 meters, or whatever, we get artificial pits and we need to fill them in, because otherwise water just gets stuck. The processing that we're working with has no concept of water flowing into one of these and becoming a lake and filling it up and then flowing back. It just says, okay, it flows into that cell and that cell doesn't flow anywhere. So, in general when a cell doesn't flow into a cell around it, or that has no downstream cells, we decide to fill it. Otherwise, these pits become sinks and suck up all the water nearby, and then our DEM doesn't actually work correctly for water shed processing anymore. So, when we fill it in, we get something like this where, originally, this would have been a pit, and this would have been a pit, and each one, coming from a slightly different error. One where the DEM's a little taller than the surroundings should be, and one where it's a little lower, and as you fill it in, you just kind of make it straight across, and the water can flow across the surface, and will keep going downhill. And this does have an effect in the overall elevation of the digital elevation model. So if we were to trace water down the stream in this river, this blue line on here is the original elevation of the river, and you see it kind of going up and down, up and down. And, an area that suppose to keep going down hill it really doesn't do that in most cases, and so the pink line shows the effect filling it, that it keeps kind of going straight across to bridge these fluctuations in the landscape here, or apparent fluctuations in the model, rather. Okay, so how do we actually, once we filled our DEM, turned it into a set of streamlines. Well, we start by determining the direction of flow for each cell, and we used hydrologic flow direction calculation. And what that means is, it's not just a slope calculation, it's specific to which way the water will flow, and that's the direction of steepest descent. And while it might initially seem like you would look at the cell in the center, say, and look at the window of cells around it and just look for the lowest value, that's not always exactly the case. So, we know it's not going to flow up hill. So it's not going to flow to any of these three here. So the steepest descent would actually go probably from one of those into here. But if we are evaluating this one cell, if flow direction goes through and evaluates each cell with kind of a moving window through the raster, if we're currently evaluating this cell in the middle here, and the elevation values are these numbers, which direction is the steepest descent? Well, if we actually do a slope calculation, taking into account the distances between the cell centres, we have to remember that the diagonals are the square root of two, length and distance, and this is one, one unit of whatever the cells are. So, this is about 1.41 in length, while this one, and when we're doing our calculations of slope, we have to take that into account, so, for slope we'd get this value minus this value. Since that's our rise or fall, so that's y over x, change in y over change in x, right. So our change in y being our actual DM levels, is the difference between these two values, and the change in x is the cell size times our unit length here. So, in this case, if it's a 30 meter DEM, then we have 30 square root of 2 going diagonally and just 30 going straight, up, down, left, or right. And our direction of steepest descent would turn out to be in this direction of this 52 here. Because, ultimately, 67 minus 52 gives us 15 over 30, which gives us .5 for our slope. Whereas, this one gives us 19 on top, but 30 root two on the bottom, which ultimately calculates to about .45. So it's a smaller slope going this way than it is going straight down. So once we calculate our flow direction, we get new values out, so that this grid here is a little different. This is showing the values that result from flowing to any one direction. So the resulting raster, this cell in the middle here gets replaced with a value based on which direction it flows. So, if it flows downward in this encoding, this cell becomes four, because flowing downward becomes four. And if we go to the right, this value becomes one, to bottom right becomes two and so on all the way around, but this isn't perfect. We might get stair stepping, because if we look at this topo map here, the direction of flow probably is straight down here. The contour lines look like maybe the flow should go this way along the red line, but if we can only go in eight directions based upon this encoding here, then, we can only go to one of these two cells instead. So, the direction is a little off and it might be that it chooses to go here, and then it goes here, and then it has to stair step again from here to here, something like that. So, it's not perfect. Again, we're working with a digital elevation model, but our flow direction itself is also a model. Ultimately, what we end up with is a grid of values based on the flow direction. So if the arrows are our concept of which direction things flow in, and things are kind of flowing along this way, this grid here shows the numbers that would actually be stored in the flow direction value that the flow direction tool gives us. Or in the flow direction raster that the flow direction tool gives us when we're done. So these cells all flow down to the right and so all three of these have the value of 2. But then, when we start flowing down we get the 4's here and we can match up these arrows in this grid all the way across. Ultimately, once we have our flow direction, we have enough information to create a conceptual grid Because if we think of this cell is pointing to this cell, then we can connect their cell centers. And then this cell flows to this cell so we can connect the center there, and then this cell flows to this cell, so we can connect that center. And this cell flows down to this cell, and we can connect that center there. And we can do the rest of this across the landscape of our raster. And start connecting cells based upon which cell it flows into or which cell it kind of points to if we have this arrow concept. And all of a sudden we have what looks kind of like streamlines. What looks like a grid network of some sort. And that's where we start building the flow accumulation grid. So when we have flow direction, the values represent which way the cell flows but flow accumulation represents how many cells have Float into that cell. So if we have that same grid here, that we built before, for once up top here, these are all origin points so no cells flow into them so they get a zero. But this cell here has two cells going into it this one and this one both flow into it so it gets two and then as it flows down again all this one has to get ten because it has one from here it has three from here and it has another three from here makes six and seven and then it has another three coming from up here all the way to ten. So you got these merging and you can just count The up string cells. The cells that are flowing in the direction that create this network become the value of the actual cells themselves. Now in the process of generating this flow accumulation roster, we don't actually ever have anything representing this network or grid, or this network here. We only have the flow direction raster which becomes the flow accumulation raster but conceptually we can think of this as what's occurring is connecting all these cells so that we can count up how many are upstream of it. But this calculation of how many are upstream actually is what is an intermediate product for us to get a layer that has this kind of connection to it. And how we end up doing that is once we have that flow accumulation rastor we can start to count up the cells with the highest values. So we might say that you need ten cells. Maybe these are 30 metre cells so that makes them 100 metres square And so then we have 9,000 square meters before we decide that it's a stream. So we start the brush holding and say okay any cell with more than ten upstream cells is really a stream line. And the reason for that is the whole landscape does potentially receive water falling on it but it doesn't all accumulate into a stream until you have enough of it kind of flowing into the same spots. To come together and have enough water to build up a stream. Or, to put that better, water flows across the surface of the landscape, but may not be noticeable as a stream until a lot of water flowing on the surfaces comes together to a low point and You have enough to make what appears to be a stream. Enough water flowing across the surface there to turn into an actual stream or river. And at that point, our conceptual stream network here, we can kind of highlight these lines through it because this is connected to here still and then down to here and on that. And we can also generate watersheds based on that by saying, okay, if we have this outlet and this network of streams that we have thresholded saying this is really a stream. But all of these cells flow into these cells down here. If I want to know what flows into this polygon or this cell here, then give me the polygon or set of raster cells that actually flow there. And that's the water shed of this point right here, is the set of upstream cells flowing into it. And we have all that data based upon our flow direction and our flow accumulation rosters. So this works a little differently once we actually start using the tools and we'll go through that the next time. But the flow direction and flow accumulation tools are the backbone of finding these river locations. And the rest of its Kind of more just processing in order to get those to give us what appears to be extremes. And to summarize it all up we need to precondition the DEM by filling it first. And then we can find the streamline locations using flow direction and then propagating it across the landscape using flow accumulation. And then getting the streamlines out of it really is about thresholding our flow accumulation values to what actually is a meaningful river or stream to us. Okay as I said, in the next lecture we're going to go through the tools required to make this work. So see you next time.