 Hello, this is Hans van der Kwas senior lecturer at IHG.institut for water education. In this video, I'll show you how to use the white box tools from the processing toolbox in QGIS to delineate catchment and streams. And we'll start from scratch. So I loaded here the OpenStreetMap XYZ tiles, and we're going to delineate the Roor catchment that they use a lot as an example in my videos. And the outlet is around Vermont, and if you delineate a catchment and you know the name of the river, you need to find the outlet, and then you need to estimate the approximate area of the catchment for which you need a digital elevation model. So you need a bit of local knowledge there, where you look at the DEM. But here I'm going to download the DEM tiles using the SCIP DEM downloader plugin. Now I've installed the plugin, and I have this icon. If I click it, I can choose here the extent, and I set it to the Canvas extent. And when I click download, it will ask my credentials. So you give the username and password, and if you don't have it, you can use that link to create a new one. And when you click OK, it will start downloading. After downloading, we can close this dialogue, and we see that we have a bit more than we needed. So we're going to remove a few. Make sure you have the right ones by checking and unchecking them to see where they are. So we end up with four tiles. And now we need to mosaic these tiles into one big roster that we can use for further analysis. We'll do that by making a virtual roster. In the roster menu, go to miscellaneous build virtual roster. Then select the four DEM tiles. Make sure you don't select open street map. And here we keep the default settings. We don't need to change anything. And it will simply make a virtual mosaic. Virtual means that it will not recreate a huge file, but it will do a mosaic on the fly. And there is the result. Now we can remove the other tiles because we will work with the mosaic. The first thing I'm going to do now is to change the projection of the project to UTM because we can't work with geographic coordinate system. But we see here that the mosaic is far too big and is much larger than the area where the root catchment is. So I can use the create layer from extent tool to draw an extent on the canvas within which I think the catchment fits. So you need a bit of expert knowledge there or interpretation of the DEM. I know it's approximately here. So it uses then the coordinates and the projection of your project. And then you can export this to a polygon. I need a temporary one. And now I can check if it still fits within the DEM. And then we're going to use that. If I export DEM to a new layer, it's called a DEM subset. Change the projection to the UTM zone. And then I calculate the extent from that temporary layer with the extent and I make the pixel square to 30 meters. And now we have our subset and I can remove the mosaic. So now we are ready to use the white box tools for further processing. So the first step to delineate the catchment and streams is to fill the DEM to make it hydrologically correct and make sure that all the water flows to the outlet and it doesn't have any artifacts as depressions. But I see here that there's a fill burn tool, which means I can burn in the river network. So I can download the rivers from OpenStreetMap using the quick OSM plugin that I can install from the plugin manager. Then in the dialogue, I can say I want waterways and I want as a value river. And I want it in the extent of the polygon that we just made. And I only want the lines. When I run this query, it will download the rivers from OpenStreetMap that fit within the extent that we defined. If the internet connection is not good enough, you can increase the timeout. Here it's downloading and now parsing the lines. And there are the rivers from OpenStreetMap. Before we can proceed, we need to export this temporary scratch layer and also change the projection to the one of the project. So I'll export it as an sreshape file, call it rivers, change the projection to UTM and then click OK. And there is the result. Now we can use the fill burn tool from Whitebox to burn the rivers into the DEM subset. They need to be in the same projections. That's what we just did. And I call the output DEM burn. And this will make sure that the rivers are always the lowest points locally in the DEM. So we'll force the water to follow the existing rivers from OpenStreetMap in this case. There's our DEM. Correct it for the rivers. I open the watershed tool and I see it needs the D8 pointer files and input and the poor points or outlets. So let's create those. The pointer file and there are different algorithms that you can use, but I'm just going to use the D8 pointer. And the pointer file is just the flow direction which has the proper encoding for use here with Whitebox. So I call it flow direction. And in documentation you can read more about this encoding. And here we see the result. And let's query the result and see because I see these big patches and I see there that the flow direction is zero. That's not what we need if we want to delineate catchments. What it needs to do is also fill the sinks again. So after fill burn you also need to apparently fill the sinks. So I'm going to use the FillDepressionsWangLU algorithm similar to the one that we have in Saga. And you see that it will fix the flat areas by default checked. That's exactly what we need. So all the water will go to the outlet. And I call this the unfilled. I run it. That's the result. We still see our burnt river. So that's perfect. And now I can do the D8 pointer again. And I'll save that then to a new name. The pointer filled. When I query I see that these are not flat and have directions. So that's what we need. Now the other thing that we need is the outlet. I look here at watershed. So we have the D8 pointer, but we also need our port points. And we're going to define one outlet for the rural river, which is in Rue Mont. So if I take open street map, I can pan and zoom to the area where the outlet is. And there we find where the rural river gets into the most. And there's where I'm going to digitize an outlet. I create a new scratch layer because it's just now temporary. Call it outlet and it's point as a geometry in the projection of the project. I add one field with the ID, which is a whole number. And then I add the point. And just give it ID number one. And now I can use snap port points because it needs to fit with our filled elevation model. And it needs there the flow accumulation, which we don't have yet. So I'm going to calculate the flow accumulation. The D8 flow accumulation also with white box. And I can use as an input the DEM or the D8 pointer file. I use the DEM filled and keep the defaults. And then I get the D8 flow accumulation. Here we see the result and we recognize our rivers, which of course have the most accumulated water. And these higher values are then visible here in the map that has a huge range. I can use snap port points now to snap our digitized outlet to the river. You need to choose a maximum snap distance. And if you make it too big, it will snap more downstream. So let's see what it does here. I run it and there it goes too much downstream. So there also will have a part of the Mose River. That's not what I want. So I'm going to change that tolerance value. Make it a bit smaller so it snaps closer by. Because I really only want the roar. So it needs to be before where it enters the Mose. Let's run snap port points again. And now with a smaller distance let's take 100 meters. Save it under a new name. And now we see that it snapped closer by. And what it exactly does is it will snap to the closest high value of the flow accumulation to make sure that you are delineating the catchment belonging to the river. So now I can use watershed. And I use the d8 pointer file and our snapped outlet. And I can define here the output file name, which I'll call roar catchment, that I run it. And it will result in cells with only value one. And there we have our catchment. And it's exactly the shape that we would expect also from the videos on how to do this with saga or with grass tools. It's very comparable. So now we can convert the raster to vector polygons with the bitebox tool in order to have the catchment boundary as a vector polygon. And let's call it roar boundary. And there we have the result. Let's style it in such a way that we can see the boundary as a simple outline. There we have it. We still have that rivers layer from OpenStreetMap. And it would be nice to clip it. So I'm going to use here geoprocessing tools clip. Use the rivers as input and overlay layer the boundary. Save it to rural rivers. And there we get the error that we also had with the saga tools. When we go from vector to raster, we get artifacts and geometrical problems. So therefore we need to use the fixed geometries tool. So we use the boundary and we fix it here. And now with this fixed one, I can use the clipping tool without any error. And we save it under a new name. And you see now it runs without any problem. You see here that the OpenStreetMap has some gaps because not everything was classified as river but maybe as other tags. So you might want to play around with having the right parts of the river from OpenStreetMap. But another thing that you can do is use the delineated river. So we still need to do that. If you go to the white box tools, then there is a tool extract streams. And it uses the flow accumulation. We have that already. And then you need to put a threshold there of the amount of material that accumulates. So the amount of cells that accumulate from that point onward will call it the river. So let's try it first with 10,000. So only an accumulation of more than 10,000 pixels will result in a river. And it will create this ruster layer with only value one. And then you can inspect it with the background OpenStreetMap layer or with the downloaded rivers. And here we see that we have many more rivers than are on OpenStreetMap. So we need to increase the threshold a bit. It will be hard to have a perfect match because in some areas the delineation does better than in other areas. The more natural and the more relieved the better it is. So let's use here 100,000. And here we see that we have now much less streams, maybe too little. So you need to play with that. But the ones that we have here are the large ones and they have a good match with the rivers on OpenStreetMap. So that's also to confirm that the burning of the rivers really helped. And it's still in ruster format. So I can use the tool ruster to vector lines from white box tools. Save the line as a shapefile. And let's call it delineated. So we can distinguish it from the other river file. And add a style. Make it simple blue. And now we see that we have more continuous rivers based on our delineation. And we can still compare it with the rivers of OpenStreetMap to look at the differences. So this iterative process where you can use different tools of white box, you see there are alternatives for filling, of burning the rivers, and different choices that you could make here. But you see that these tools are very fast to calculate and very useful for hydrological analysis. So stay tuned for more videos on this in the near future.