 Oh, welcome back on my YouTube channel. Today I have a cool tutorial for you on how to make a graphical model in QGIS that lets you pick any location on the map with a mouse click. This model will store the coordinates of your click in a point vector layer. Then I'll show you how to apply this in a model to draw streams and catchments for any location you choose. You can get this model from the resource sharing plugin which I've covered in some of my previous videos. So let's get started. I've added a backdrop from OpenStreetMap and I'm going to create a new model from the processing toolbox. I maximize the model designer window. Here you see the inputs. This video is about this point input where the user can click on the map canvas and the coordinates will be used in the model. In this little example we're going to create a layer from the point. I use this create layer from point tool then I change this to the model input which is point and then we save the point layer. Give the name point to layer and I make a group test. I save the model in my profile. Let's test the model. I find the model under models test point to layer. If we double click I can run the model. I click the browse button, I'm asked to click on the map canvas and that gives the coordinates in the projection of the project. Then I can save that to any vector layer. Let's save it as a dual package. Let's test and run it. And that created the point at the location where I clicked. Let's apply this now to stream and catchment delineation. For this model I assume that you have installed the PC Raster Tools plugin and the Open Topography DM Downloader plugin. The installation of these plugins has been covered in other videos. I'm going to create a new model and this is going to be a big one. I'll start with giving the model a name, stream and catchment delineation and I saved in a group hydrology. The first input that I'm going to add is extend because the user needs to specify the extent for which the Open Topography DM Downloader plugin will download the DM tile. Next I need to add a string for the Open Topography API key. Then I can use the Open Topography DM Downloader tool and we're going to set it to the 30 meter DEM for this tool and for the extent we use the model input study area extent and for the API key we use the Open Topography API key input. Let's save the model. Next I want the user to define the output projection. I use the CRS input and it should not be EPSG4326 so I set the default on project CRS. Then I want to reproject the downloaded DM and I use the warp reproject tool. As an input I want the algorithm output which is the result of the Open Topography DM Downloader and I specify that the target CRS is our output CRS input. I keep nearest neighbor resampling. I change no data to minus 9999 and the output file resolution to 30 meters. Next step is to convert this file to the PC Raster format and I'm going to specify that in the description I want to convert DEM to PC Raster format and I use there the output from the warp algorithm as an input of this algorithm and scale our output data type because the DEM is continuous and I also want the user to be able to store this output. The yellow boxes are input, the white boxes are processes and the green boxes are outputs. The next step is to create the local drain direction map or flow direction map. Change the description, calculate flow direction. Change the DEM layer to algorithm output and choose there the converted PC Raster DEM. The next step is to calculate the Strahler orders and we do that with the stream order tool from PC Raster. Change the description to calculate Strahler orders. There's an input we use the algorithm output which is the local drain direction layer. Now we're only interested in Strahler orders above a certain threshold that the user needs to define to consider those pixels as part of the river. So we need another input, I choose a number input and that's the Strahler order threshold that the user needs to give. It's an integer number type. The minimum is always one and I put a default value of five. Then I need to create a Raster from that number and I do that with the spatial tool. Now change the description, create Strahler order threshold Raster. That basically converts this Strahler order threshold which I create here as a model input to an ordinal Raster with just that value and the mask layer is the local drain direction layer. I'm going to move it a bit. Next step is to use a comparison operator to select from the Strahler orders the pixels that are larger or equal to the threshold Raster. I change the description to select Strahler orders larger than or equal to the threshold. The first input Raster is the algorithm output and there I select the Strahler order layer. Comparison operator is changed to larger than or equal to and the second Raster layer there is an algorithm output and that is the threshold value. That results in a Boolean layer, River, not River pixels. And then with the if then tool, we can add again the Strahler orders to the true pixels. So we'll end up with the River with pixels of the Strahler orders. We change the description, assign Strahler orders to River. The Boolean condition is an algorithm output and the second Raster which is if it is true, then assign the stream order result which is the Strahler orders. Now we want to convert this to a vector layer and if you want to convert Raster lines to vector lines, you need to use a thin tool to make sure that the pixels of the River are only one pixel wide. So I use R thin from grass and as an input, we use the output of the last tool. Change the description, thin River Raster. And I use the grass R2Vect tool to convert this now to vector line. Now change the description, convert River Raster to line. As an input, we use the algorithm output of the thin result. Each type is line. We keep everything as default except use Raster values as categories instead of a unique sequence. So it will use the Strahler order values which will result then in a line with the Strahler order values in the attribute table. Now on the way, we lost the projection. So I'm going to assign the projection here. This has to do with the intermediate PC Raster results which are in temporary files and do not store any projection information. So here I use assigned projection and I assign it to this last result where we factorized the Raster line. And we use here the CRS from the user input. Another issue is that if you go from Raster to Vector, you have a lot of geometrical issues and we can use simply fixed geometries to fix some of the issues. We keep the default repair method and here we can output then the streams. As we organize this a bit, it takes too much space. I can select all and I can add a group box. With the group box, you can make compartments of your model and this model will have two compartments. The first part is about delineating the stream network. That's what we just finished. Now we call this box stream delineation and we can give it a color. Let's make it a light blue. And then we can proceed with the second part which is the catchment delineation. For the second part of the model, we need as a user input the point with the outlet selected from the map canvas and we need to create a layer from that point which uses as a model input in the select outlet point on map input. Then we need to re-project this point to the defined projection for all the output layers. I'm going to use as an input the algorithm output which is the point then I use the output CRS input and the user can see this then in the output as the original outlet. Next we need to snap this outlet to the river that we have just delineated in the first part of the model. There's an input, I use the algorithm output which is the re-projected point. And as a reference layer, we use the line factor from the fixed geometries. Here we can set the tolerance of the snapping. You can play with that figure but by making it a kilometer, it will snap to the closest line, hopefully. Otherwise you can just change it to 500 or something else or make it an input. At the behavior, I'll change it to prefer closest point but insert extra vertices where required. So it will go to the line and add a point on the line if it's needed. And the user can save this as the snapped outlet. Let's reorganize it a bit. Next, we need to rasterize this point. I use rasterize factor to raster. Change the description to rasterize snapped outlet to make it clear. As an input layer, we use the algorithm output which is the snapped geometry. We want it to have a pixel value of one. The output raster size units should be in geo-referenced units and then we can define that that's 30 meters. For the output extent, we should use the model input of the study area extent and the no data value is minus 9999. The next step is that we need to convert this to the PC raster format. Change the description to convert outlet to PC raster format. For the raster layer, I use algorithm output rasterized snap outlet and make it data type Boolean. I need to resample this result in order to make it exactly fit with the raster layers from PC raster in the stream delineation part of the model. There's an input I use here in the convert to PC raster. As a mask, I use the local drain direction layer. Then I can use the catchment tool in this pixel. I change the description to calculate the catchment For LDD layer, we use the local drain direction layer and for the outlet layer, we use that outlet converted to the PC raster format that was resampled. Then this is the catchment in raster format in the description. So I'm going to use the polygonized tool from GDAL to create a polygon out of this raster catchment. In the input layer, I will use the algorithm output which is the catchment raster. Keep all the defaults because our catchment has a polygon with attribute dn equals one. I need to extract that by an expression. With an input, I use the algorithm output of the polygonized catchment raster. The expression is in double quotes dn because that's the field equals one. It relates back to the Boolean one that we created of the outlet and then the catchment got also value one. And I save this then as the output catchment boundary which should be then one polygon. Let's reorganize it a bit. Add a group box and we'll call this one catchment delineation. Give the color, make it green. I'm finishing touches, but it looks better. Add it to help string. This is like a wizard where you can fill in the different parts of the help string. Reorder the inputs in such a way that it's more logical for the end user. Save the model. We can close the window and then we can run it. I'm going to use our new model to delineate the faster catchment. I run the model from the process of toolbox and I define first the study area extent by clicking this button. Then I select the outlet point on the map. Using name. There's the faster. And let me take the point at that bridge. Takes the coordinates. I use Australia order seven. Paste the open topography API key. Save the results to the files. And then we run the model. In this case, I didn't change the output projection. And here's the result. Let's move the catchment boundary a bit upward and zoom to the layer. Here we clearly see the shape of the vest catchment and the river lines. And in other videos, I have demonstrated how to style this properly. So here I'm going to do a fast forward with inverted polygon shapers fill and the hill shape landing. Interpolated line renderer for the river. And that's the result. So in this video, you've learned how to create a graphical model which uses coordinates selected on the mud canvas by the user. You can also download this model through the resource sharing plugin for PC Raster. How this works is explained in another video and you can find the link in the description of this video.