 Hello, welcome back on my YouTube channel. In this video I'm going to demonstrate how to add contour lines to a ground water level map. We'll use two methods. First we'll use the contour line renderer to on the fly create the contour lines, second we're going to calculate the contour lines and add them to the map with some styling. To render the contour lines from a ground water map I'm going to duplicate the ground water level roster that I've created before in another tutorial. I drag the duplicate to the top and I'm going to rename the layer. Remember that a duplicate of a layer is referring to the same data as the original so I'm not creating a new file, I'm just creating a new style based on the same data. I rename it to contour lines and as you can see it's a copy. I switch it on and then I go to the layer styling panel and make sure that contour lines is the active layer and I choose the contours render which on the fly renders contour lines. I can change here the contour interval to an equidistance of 5 meters which works best for this data set and I can indicate a contour interval and I use 25 meters which you can't see it yet so I'm going to make some difference by changing the color of the contour lines of 5 meters to gray, you can choose a light gray here and then the dark black lines are the index contours. With input downscaling you can change the generalization of the lines but here 4 already gave a good result. The disadvantage here is that you cannot easily add labels and that it cannot be used in further calculations or in your groundwater model. For that purpose we are now going to derive the contour lines from the raster. Go to the raster menu and there under extraction you find contour. In the dialogue make sure you choose the interpolated groundwater level layer here and set the interval between contour lines to an equidistance of 5 meters. You can add an attribute name that will be the field and attribute table indicating the elevations of the lines, I call it Z. I keep the rest as default, you can also produce here a 3D vector which is not needed in our case. I'm going to save the file, note that you can't save it to an existing geopackage so here I just create a shapefile which I can later import in my geopackage. This result we see that the lines are styled with one color which is randomly assigned so now we're going to work a bit on the styling. Now the idea is to replicate the styling of the on-the-fly contour renderer that we've used before but therefore we also need to indicate which lines are the index contours at 25 meter interval. We can derive those through a calculation in the attribute table so I'm going to open the attribute table, toggle the editing mode and open the field calculator. I'll create a new field which I call index. It's a whole number and it will have only one digit which will be a value 1 for all the index contours. Therefore I need to use a conditional and the conditional that I'm going to use is the if and if you select a function here in the middle you can find the explanation and examples on the right side. So here I say if the Z field and now I need an operator I'm going to use this modulo operator which gives us the remainder of a division. So if Z is divided by 25 and the remainder is 0 so it means it can be divided by 25 then give me a value 1. If not then return no data and therefore we can use null. Close the brackets and here is our expression. So if the remainder of dividing Z by 25 is 0 then it's an index value otherwise return no data and here I see the result so we can use that further in the styling. So toggle off editing and save the edits. Now change in the layer styling panel the renderer to categorized for the contours layer and choose the index layer as the value then click classify. It will add two values value one and all other values that captures the no data values. So value one here with the random color blue is our index line and the other lines are red. So I'm going to change the color of the index contours to black and of all the other contours to gray. I can use the recent colors to make sure that I have the same colors that I've used before in the contour renderer. Now I'm going to add labels which is possible in an easy way with this attribute table. So I switch to single labels and we don't want the ID values but the Z values there and here it has placed the labels but not in a really readable way. So I'm going to go to the placement tab and choose a curved mode and I want the values on the line, switch off above line and for longer lines I would like it to repeat the value. So it's easier for the reader to see where the line is, what height it is. So I choose a distance of 150 millimeters that's still not very readable because the values go through the lines and have the same color. So I'm going to add a little text buffer and I'm going to reduce the text buffer size to 0.5 millimeters. And now we have a nice result so we have our contour lines calculated and the labels added. I can further style this in a print layout to create a map or I can use the contour lines in a model. In the processing toolbox if you search for contour you find two different tools, the contour tool is what we have already used but there is also a tool to create polygons instead of lines which you sometimes need. I hope this was useful, please subscribe to my YouTube channel if you want to receive updates.