 Hello, this is Hans van der Kraas, Senior Lecturer at ICH Delft Institute for Water Education. This video will demonstrate how to derive a catchment and its streams from an SRTM digital elevation model. The procedure in this video will use the new PC Raster Tools plugin. So make sure you have it installed in the correct way. We'll really start from scratch, so we need some orientation. You can use the Quick Map Service plugin, which can be installed from the Plugins menu. Search for Quick Map Services and install the plugin. Click Close. The plugin is installed in the Web menu. But here you see that the list of options is quite short, but if you go to Settings, you can go to the tab More Services and click Get Contributed Pack, which will install many more Web Map Services. Here you see the complete list. We're going to use the Open Topo Map, because we need some topographical information to make an estimate of where approximately our catchment is located. We're going to derive the Roor Catchment, which has an outlet near Vermont, but we need to look at the river systems on the map and the mountains to see where approximately the area is and to zoom to that area. Once we've determined the approximate study area, we can create a polygon layer from the extent. In the Processing Toolbox, search for the tool Create Layer from Extent. There you can use the drop-down menu to use the map canvas extent. However, the coordinates here are in the coordinate system of the background map, and we need to use the coordinate system of our project, which in this case is UTM Zone32 North and WGS84. So I changed the projection of the project to 32632 as EPSG code, and then I can use the map canvas extent. And now it uses the correct coordinates. I save the file to bounding box, make it a shapefile, I run it, and there it is with the default color. Let's style it to make it a nice boundary line, so I use outline simple line, a little black line there to indicate the boundary of our study area. The next step is to download the SRTM tiles. You can do that from USGS Earth Explorer, but there's also a nice plugin. It's called the SRTM Downloader Plugin. Install the plugin from the Plugins Manager. Click close after installation, and it has added this icon here to the toolbar. Click on the icon, and click on set canvas extent. It will now use the boundary coordinates of your map canvas. You can click the download button, at some point it will ask for your credentials to log in to the portal where the data is downloaded from. Use the link to create a new account, or if you already have an account, type here the credentials. You can also save the credentials, and then it starts downloading. If it's interrupted, you just click download again. Like here it says connection closed, just click download again, and it will proceed. If this doesn't work on your computer, then you can use the USGS Earth Explorer web interface to download the tiles. So it has downloaded four images, then click close, if I zoom out I see it covers a much larger area than our extent that we have determined for our study. Because we can't work with all these separate tiles, we're going to mosaic them. The easiest way is to make a virtual raster. We go to raster and select build virtual raster, and we choose there the four tiles. We keep the default settings here as they are, and we save it to a new file. This will be a very small file, which does not really copy the whole data, but just provides a virtual link to the data, and it's very efficient, because we don't want to continue with this whole data set all the time. And here we see it. I can remove the separate tiles, and I drag the bounding box to the top. Let's change a bit the style of the bounding box, so it's clear with the grayscale background. Make it red. And you see that our study area is much smaller than this mosaic of the DM tile. So we need to clip and re-project, and the easiest way to do that in one step is to click right on DM mosaic, and then choose export, save as, and there choose a file name, go to DM clipped, and I can choose the bounding box as the coordinates, but I first need to change the projection to the one of the project, otherwise it will be in latitude longitude coordinates. Let's do that again. Now with the correct coordinates, I'm going to change the horizontal and vertical resolution to 30 meters, and I use as a no data value and out of range value, which is minus 9999, which is often used. I click OK, and it's performing the clip and re-projection, and I can remove the mosaic, and there is the result. Let's quickly style this DM. It's a continuous raster, so we use the single-band pseudo-color renderer. There we can use the drop-down to select a new color ramp, and we're going to use the catalog CPT city, which has a lot of nice presets. There we go to topography, and we can simply choose elevation, or any other one here that we like. Then we need to click classify to apply the colors to the pixels in our DM. Then there's a nice trick to add the hill shade to the DM colors by using blending. So we're going to duplicate the DM layer, and it's good practice to rename the layer, called hill shade, and let's make that one active, and here I use the hill shade renderer, which on the fly renders the pixel values to hill shades. When I zoom in, it gets a bit blocky, so I change the resampling to bilinear for zoomed in and cubic to zoomed out. Now I can use the blending mode on the DM clipped layer, and I use multiply, and this gives a nice effect with adding the hill shades to the colors of the DM. To further process the DM for catchment delineation, we need to install the PC Raster Tools plugin. There are alternative ways using grass or saga, there are also videos on my YouTube channel about that. But the PC Raster Tools provide a robust way of deriving the catchment and streams. PC Raster has a GDAL supported format, but we need to convert our DM first to the PC Raster format, so therefore we choose the tool convert to PC Raster format, and it's important to choose the correct data type, which is scalar. Scalar is used for continuous rasters, and PC Raster is strict on the data types, and we always check that when you perform the tools. So now we have the DM in PC Raster format. The next step in the workflow is to fill the things and to derive the flow direction. PC Raster does this in one step using the LVD create tool. You can find in all these tools a link to the documentation, which describes how it works and what the different arguments are that you can give to the tool. Here you see the different arguments, and their descriptions, and it will result in a flow direction map with the directions encoded with these numbers, and these numbers correspond with the numeric pad on your keyboard. The different settings of filling are illustrated with this figure, and you can find some examples on the bottom of the page. We use the DEM of PC Raster as an input, and we keep all the defaults to fill to the maximum possible, therefore we use those large numbers. This flow direction has an output, and I run the tool, which can take a while. This is the most intensive calculation that you do in this procedure, so be patient and just wait until it finishes. You can close the dialogue after processing, and now we can have a look at the result. The flow direction is a discrete roster with values for the flow directions that correspond with our numeric pad. To have a look at it, I use the palleted unique values renderer, and to see the unique values in the roster, I click classify. Here we see the different numbers, the colors they don't really make sense, so we need to style this in a better way, and for flow direction we need to use directional ramp. Because the PC Raster values are not very organized in a linear way, I'm going to convert the values with a lookup table to the ones used for Saga. So in our case, value 1 is the south-west, and in Saga that is value 5. Because Saga starts at 0 for north, 1 for north-east, 2 for east, etc., while PC Raster uses again the numerical pad of your keyboard. Special value there is 5 for PC Raster, which means flat, and in Saga that is 255. So this will be our lookup table, which converts the PC Raster directions to the Saga directions. Make sure you change the range boundaries to be exactly the minimum and maximum, and for the output format you can use byte, because it's 8 bits, which can store values from 0 to 255, which will be sufficient. Let me save it to flowdirector.tiv. After processing, close the dialog, and then you can start the styling. Go to the Layer Styling panel, switch to Paleted Unique values, click Classify, and here we see the numbers 0 to 7 and 255 corresponding with the Saga flow direction values. We remove the 255 because we're going to create a ramp for the other numbers based on the spectral color ramp, so we choose the spectral one, and we can click on the ramp and say Edit Color Ramp, and there we can modify those stops. First we're going to make the first color the same as the second one by picking the color. Then we change South to Yellow, which is R255, G255, and B0, and for East we make R0, G255, and B0 to make it green, and then for West we use MacInta, we create that by using combination of 214, 60, and 170. If you want to do it very correct, you also need to change the last stop, which will be the Northwest, to a color that is somewhere in between the MacInta and the blue, so somewhere between the Southwest and the North, and click OK when you're done, and then the color ramp is applied, so here we have a directional color ramp. The problem is that we still need to add 255, if we click the plus it adds 8, but 8 doesn't exist in the dataset, so we need to type 255 for value, and then we can type the names of the labels to make it human readable. So each of the value numbers corresponds with a flow direction that we need to type as a label. 255 is flat, and therefore we also give it a white color by changing RGB to 255, 255, 255, 255, and we type here flat, and there's the result, which we also see in the legend in the layers panel. You can use blending with the hill shade by putting the hill shade below, and changing the blending mode to multiply for the flow direction, and when we zoom in we can see then some patterns, if you go to the hills, and we can interpret these colors, and we can use a little bit of smoothing by changing the resampling settings there. So that's the result of the flow direction map. There are other ways to style the flow direction map using arrows, which is explained in another video. The next step is to derive our streams, and therefore we need the strahla orders. You can also use as an alternative the flow accumulation using aquiflux, but here we use the stream order tool from PCRuster to calculate the strahla orders. As an input we use the PCRuster flow direction, so not the one used for styling, and we save this as strahler, and then we run the tool, and it results in this nice map, for every pixel strahla order, and we can style this, and larger the number, the bigger the stream, so we can use palleted unique values, because it's an ordinal scale, and we use their blues as a color ramp, and I click classify, we get this nice effect where the darker blue pixel gets the bigger the river is. In reality not all pixels belong to a river, so we now need to do some calibration to determine which strahler order threshold should be used to consider a pixel as being part of a river, and we can do that by calculating Boolean maps with strahler order larger or equal than a certain value, and compare that with OpenStreetMap, or with a satellite image from Google Satellite for example, and then the threshold that matches best with what we see on the map, or on the satellite image is then the value that we use for selecting the rivers from the strahler order map. So we can do that by using the raster calculator, and I double click on strahler, use the larger than or equal button, and I start with a value of 5, and then I save the result as strahler5, the output will be TIFF files in this case, click OK, and there we see the result, and I use this styling from the palleted unique values, remove the zeros, keep the ones, can make it blue to correspond with the color of rivers, and I need to remove some of the layers below, and hide all, keep the strahler5, and here I'll use OpenStreetMap as a background, and then I compare the result, and I can already see that there are far too many streams when I use order 5, so too many tributaries. So you repeat this for different values, I'll now skip a few values, and go to 8, called strahler8, I can copy the style to save a bit of time, and uncheck strahler5 to see the difference, we see now that many tributaries have been removed, and this one looks like it corresponds quite okay with the rivers on the map, the amount of tributaries, that's what we control with the threshold, and it is a calibration of a model, so you will never get it perfect, but try to find the best result here. So now we can use that threshold value that we determined for further analysis to derive the streams. So I go here to the spatial tool, the spatial tool simply creates a raster with a data type based on a value, so all the pixels will get that value in that data type, and I use here a value 8 on an ordinal scale, and I use strahler as a clone, and I call this ordinal8, and there's the result, all pixels have value 8, that is because the PC raster tools use mostly maps as inputs, so I can now use one of the conditional and boolean operators here, the comparison operator, and then I say if input raster which is strahler is larger or equal to ordinal8, then give me boolean2, otherwise give me boolean false, so those will be our channels, this will tell us boolean2 for channels and boolean false for where there are no channels, we'll paste the style here again and it will end up with the same map when we have strahler8, but now I want to have the strahler orders for the river, so I need to use if them, so the boolean condition is that if there are channels, so if channels is true, then give me the strahler values, else give me no data, that's what if them does, with if them else you can also control what happens if it's false, I run this and now I see that our pixels of the river have the strahler orders which I can style with pelleted unique values because it's an ordinal scale, use the blues again and there we see that it has 8, 9, 10 and 11 as order for this area, of course it's much nicer to present our channels network as vector lines and therefore we need to convert the raster to vector lines and an essential step there is to use the r.pint tool from grass to make sure that the raster lines are only one pixel wide and not as in this case multiple pixels, so as an input I use channel strahler, I keep the maximum number of iterations and I save the output to a geotiff, I call it channels thin, make sure you change it to geotiff and then I save the result and run it and there we see the results and we can now compare channels thin with channel strahler and we see the difference that it has on one pixel width now, but we also see that we can suspect some other geometrical problems later when we convert it to vector which we'll do now, so I use r2vect from grass, use channel thin as an input, line feature type, I check the box to use raster values as categories instead of unique sequence that makes sure that it uses the pixel values and not give unique numbers, choose to line and I save the file and call it channels, I click run and when it's done close the dialog and there we see the result, it's not perfect there are some geometrical issues like overshoots and dangling nodes but overall this is something we can now proceed with, there are procedures to correct this but that's out of the scope of this tutorial, let's have a look at the attribute table of our channels vector layer that we just created, click write, open attribute table and there we see that the cut field contains the original raster strahler order values, but we need to change that into real strahler order, so I add a new field order with length 1 and I'm going to write here an equation to convert them, I use the case when then end function and I write here when cut equals 8 then give value 1, so all values 8 will turn into strahler order 1, when it's 9 make it strahler order 2, 10 will be 3 and 11 the maximum in our case will be strahler order 4, then I need to close this with the end statement here and when I click okay now we see that those orders have been applied, so those are the real strahler orders from the method because the raster ordering system gives every pixel strahler order on reality only the streams get an order, then I can use the graduated renderer for the vector styling, I use the order field and I use the size method and change the size from 0.3 to 1, change it to equal count and then we need to change the legend to discrete strahler order numbers, you can also change the precision then you have to type again, change the color to something blue and now we see how our strahler orders nicely styled, so the thicker the line the higher the strahler order and the bigger the river in newer versions of QGIS you can easily use tapered line styles, there's another video that explains that, there's still an issue that it still looks a bit blocky because of going from raster to vector, so there's a way to smooth this a little bit, so we can look for a smooth tool here in the processing toolbox and I want to do this with in-place editing, therefore I click that button there in the processing toolbox and I use five iterations here in the tool and the advantage of in-place editing is that it will immediately save it in the layer and not in a copy, you can inspect if it's okay or not otherwise you choose another iteration value and then when you're okay with it you save the results and the whole line is selected so we need to unselect and here we see that it's now smooth, so now we can compare the result with the map, so I switched on open topo map you can also use open street map or google satellite and see how well the smoothed line matches with the river system and here in the upstream it does it quite well, downstream is a bit more human modified and now let's look for the outlet to do our final step which is deriving the catchment from the outlet, so there's the rule river on the map and here's the mouse and where the rule gets in the mouse we have to choose our outlet and that needs to fit with our model, so we need to use the delineated stream, so we either use channels thin or channels stroller for that, then we click write, copy coordinate and use the map coordinates, paste the coordinates in notepad and add comma one, so it's a comma separated file with x, y and id number, if you have more outlets for which you want to derive the catchments you can add multiple lines to this file and it will with the catchment tool or the sub catchment tool derive all the catchments and sub catchments that you list here, so save it to a text file and then I can use the tool to convert this to a map, so column file to pc raster map choose outlet.txt that we just created, as a mask we use the flow direction and output data type is nominal, so when you have multiple points each catchment will have the values, the nominal numbers that it finds in the outlet map, we choose close, now to below our open topo map so I need to drag it to the top then I can style this, always good to check if the result is what you think it is, so it only contains one value, one nominal value, one in this case for the outlet and that's the outlet for which we are going to derive the catchment, so I'm going to know which area drains to this point, I use the catchment tool for ldd, I use the flow direction layer for outlet, I use the outlet and I save the result as a catchment.map, I run the tool, now I click close, zoom to the layer, now all the pixels with value one belong to outlet one, so if you have multiple outlets they will have their unique numbers, now it's much nicer to present this as a polygon, so we can use polygonize from master conversion, use the catchment layer as an input and then save the output and let's call it raw catchment, I run it, that's the result, I open the attribute table because I only want the catchment boundary and you see that there are multiple features here with values zero and values one, if I zoom to a one I see that there are some geometrical issues there because of going from vector from raster to vector, so I'm not interested in those individual pixels but I want to know the whole catchment and here I found it and what I can do here is invert the selection, double on the editing mode and simply remove everything that is not the catchment by clicking the trash bin and save the result, so there's our catchment boundary polygon, note that there's a little donut hole in it, that's because of one of the mines that has its own little catchment inside the catchment, the fill sinks, algorithm didn't solve that part, so I can now use a technique called inverted polygon shape burst fill, so I change the renderer to inverted polygons and the other symbol layer type to shape burst fill, I change the first color to gray, so 000 is black, 255, 255, 255 is white and every combination in between of equal values of RGB results in a gray intensity, the second color is white and I'm going to apply opacity of 65 percent here and you can see the effect on the map canvas in real time, so set the distance to 4 and I'm also going to increase the blur strength to 10 and now you can really see the catchment popping out of the map canvas which is a very nice effect if you want to highlight the study area and to shade the areas that are outside, I also want a black line so I added a second symbol layer and added a black line with a stroke width of 0.46 millimeters, I want to apply this or visualize this with the DEM and the hill shade I have to rearrange the layers a bit, move the channels to the top, in fact it's nicer to have the catchment boundary on the top so it shades the rivers that are outside, you can also clip that in the tutorials written how to clip it, use the hill shade there, put it below the DEM and that's a nice result, the DEM with the hill shade highlighted in the study area with the rivers on top of that, let's clip the rivers, we choose channels here as an overlay, I choose rural catchment, we call it rural channels, run it and move it to the top and I want to copy the style so I don't have to do that again and there it is, but now this looks great and we can use this further for our map design, now if we want to store all this data that we created we can package this in a geopackage so we use the package layers tool and we select the input layers that we want to package and I'm interested in rural catchment and rural channels only and you can see here that the checkbox saves the layer styles also in the geopackage that's very useful, everybody who uses the geopackage will then have the styled layers with the same styles as we defined here, note that we can only store vectors in this way, if we want to store a roster we can drag it to the geopackage, so here in the browser panel we see our geopackage and I'm going to add here the dmclips layer, the geotiff and I drag it to our geopackage, when I release it it's imported and there will be a message that import was successful, click okay, if I refresh the browser panel I see now that dm is also there but it doesn't have the styling, so what we need to do for our project is to make sure that the layers refer to the layers in our geopackage and not the ones that we have on our hard discuss files, so I'm going to copy the style of the dm to the one of the geopackage and remove the original one, for the hill shade I can simply recreate that by duplicating the layer renaming it to hill shade and then choosing the hill shade renderer, so I remove the original hill shade and I add the rule catchment boundary, if you hover your mouse over it you can see if it's the shape file or if it's from the geopackage, so here are all our layers from the geopackage at the top I can remove the others, now we can also save our project in the geopackage, so we have everything together in one file in the geopackage, so I choose rule data and I save it as rule, so now our project and the style data are in the geopackage and can easily be shared with others and we can use this for further processing or adding other data