 Hello, welcome back on my YouTube channel. In this video I am going to show how to calculate the basin length. The basin length is defined as the surface area of catchment divided by the longest path, the longest flow path to the outlet. This video assumes that you have already followed the steps to derive your catchment and streams. You can see that in other videos on this channel. To calculate the longest flow path we need to calculate the distances from each pixel to the outlet. There is a tool in the PCRusterTools plugin which is called LDDist and it needs some info that we need to create first. So the cells to which the distance is calculated in Boolean, that's the outlet, and a friction layer which we set to 1 to count each pixel as a distance. When we have derived the catchment we use the nominal as the data type for the outlet so we need to convert it to Boolean because that is needed for the LDDist tool. I use convert layer data type, choose outlet as input and the output data type Boolean. Let's save it as outlet Boolean. Now the problem is that that outlet layer only has a value 1 and doesn't have 0s. For LDDist you also need 0s. So I am going to create a layer with only 0s, Boolean data type, and I call it Boolean 0. And this results in a raster with only the 0s. And now I can use the cover tool to combine it with the outlet which has only value 1. So 1 pixel with value 1 from the outlet. So I choose here outlet Boolean. Then I choose to cover the node data values with the Boolean 0. So all the node data values will be changed to Boolean 0. Then I call this outlet 1, 0. And this should result in a layer with 0s and 1s. Let's just check that by styling. It's always good practice to style and check the results to see if that's what's expected. Because it's just one value of 1, the outlet, we have to zoom into the outlet to check that. So there are original outlets and here we have the 0, 1 layer. So that looks good. And with that we can proceed to the next step. We also need a friction layer and we need a raster with only scalar values 1 for that. And if we use value 1 for the friction, then we have the distances in map units. Let's call it friction and here we have our raster with only value 1 in scalar data type. Now we have all the inputs to calculate the distance from each cell to the outlet with the LDD disk tool. I choose flow direction as the LDD layer, outlet 1, 0 as the cell to which the distance has to be calculated and the friction and I call the output distance. There's the result. Let's check it. So we see that the distance is calculated for the catchment and let's style it. It's a simple color ramp and that looks good so we can proceed with this. But now I want to know the maximum distance in this map and therefore I can use the map maximum tool from the PC Raster Tools plugin. I use distance as an input and I call the output max distance. So with these map tools, the tools that start with the name map, it will calculate something based on all the pixels so that's a global operation and each cell in the output has that value that is calculated. So in this case, the maximum distance in the catchment is that amount. Now I also need the area of the catchment in map units so I have this catchment map that we derived when we did the catchment delineation and these are two classes with 0 and with 1 and I can use them from the area operations, the area area tool to calculate the surface area of each class. So I use catchment as an input, which has these two classes and I call the output catch area and there's the output. Let's have a closer look at it. There's just two values in it so I can use palleted unique values and there we see that all the blue pixels have that value for the surface area. Now we can use the raster calculator to calculate the basin length, which is defined as the surface area of the basin so I use catch area divided by the maximum flow path, so the max distance. I can use it on the fly layer if I'm just interested in the value, I call it basin length and there's the result and you can also style it, you're not expecting many values so we see here that the red pixels have a value of around 10.5 kilometers, which is the basin length in this case. So in this video you've learned to calculate the basin length using the PC raster tools and I hope it was useful for you and if you like these videos please subscribe.