 Hello, this is Hans van der Kwaas, senior lecturer at IHE Delft Institute for Water Education. In a previous video I demonstrated how to extract the longest stream from a river network. In this video we are going to automate the process using the graphical modeller. We will also see that a little different approach was used here, which is more generic. So I use here as input files, file with the junctions, but that can be any vector layer that you have which has springs in the outlets, and the channels layer, that's the network. Let's start building the model. In the processing toolbox choose create new model. This is the interface of the graphical modeller. Let's first define our inputs. We need a vector layer where the user can input the channels network, which we will use for the routing. It should be a line vector, and the second input data that we need is the layer that has the springs, and I use here a vector of features, so the user can use a selection from attribute table. Like in our case we want in the junctions file type that equals the springs, and it should be points, so there it is, and then the third input that we need is the outlet. Then the algorithms that we use that needs to be indicated on the map as a point. So therefore we use point, but the user can click on the position to which the distances need to be calculated from the springs. So here we have our inputs in yellow. Let's use the algorithms, and the algorithm that we need here is the shortest path layer to point from the network analysis because our layer has the springs, so let's change here the description so it's clear, shortest path from the springs to the outlet, and we keep the network as channels network, that's the line that automatically detects it, and then the vector layer with the start points are the springs, and then the endpoint is the outlet input that is selected on the map. With that the algorithm can calculate the shortest path, and then we want of course to extract the longest of those paths, which is the longest stretch in our river system. And we can use their extract by expression, so we can make a tool extract longest stream, but we need to know what expression, so what I'm going to do is to run the tool first without this, and then see how the fields are called and what expression we can use. So go back to the shortest path tool, and there in any algorithm if you write the result it will create the result, so this is the green box which defines the output file that will be written to disk, and that also the user can choose the interface. I'm going to give our model a name, longest stream in channels network, and I give a name of a group to which this tool belongs, so if in the future I have more they'll be grouped under that name, and I'm going to save this under my profile where the models are automatically stored, and then I can run the model and see what the shortest path result is before we continue building it further. So interface works nicely, I choose the channels, I click on the outlet, and from the junctions let's make them the selection for the springs, so go to the attribute table, I can select my expression, and choose type and then equals spring, and click select features, so now all the springs are selected in the file, and check the box to use those selected features only, and then I run it, and now I get the shortest path from all the springs to the outlet, there here, and we see that there's the cost field which gives the distance, and what we need to do is find an expression to get the maximum distance, so the feature with the maximum cost value, so let's extend our graphical model with that, first I'm going to remove this output, and go back to edit our model, I'm going to remove the output here because we don't need to write that yet to disk, and then I use another algorithm where we can extract attributes by writing an expression, I'm going to rename the tool, select longest stream, and the input is of course our shortest path output, and then I can make the expression which is that it should be the feature for which the cost equals the maximum of all the cost features in the attribute table, and if it matches it will be the longer stream, I save the model, and I'm going to select from the attribute table our springs, and this is very generic, so this will work with any layer where you can select the features that are springs or sources, now they're selected, so we can run the model, we can use any stream network, and we need to select the outlet, I do a bit rough now, and I use only the selected features, and I click run, and it runs our model, click close, and when I hide the channel network I see that now the longest stream is remaining, when I open the attribute table I can also see the cost field which gives the total length of that stream, it's not exactly the same as in the other video, that's because I clicked it a bit roughly where the outlet was, you can do that more precisely, so we have built a nice tool that can be used in a generic way to extract the longest stream from a channel network