14. Derive groundwater contours
We'll continue with the IDW result and will add contour lines.
An easy and quick way to visualise contour lines is to use the Contours renderer in the Layer Styling panel.
1. Make sure that the GW_level_IDW layer is completely visible in the map canvas.
2. Duplicate the layer, rename it to Contourlines and drag it above the GW_Level_IDW layer. Also check the box to make the layer visible.
2. In the Layer Styling panel change the renderer from Singleband pseudocolor to Contours.
3. Change the Contour Interval to 5 m and the Index Contour Interval to 25 m. Change the Contour Symbol to gray.
The map canvas should now look like this:
With the Input Downscaling setting you can change the smoothness of the lines. In this case the default is already smooth.
This is nice for visualisation, but not for calculations. Furthermore, we miss the labels with values of the contour lines. So, let's create a layer with contour lines.
4. Choose from the main menu Raster | Extraction | Contour....
5. Choose the GW_level_IDW as Input layer, change the Interval between contour lines to 5 m. Set the Attribute name to Z. Keep the rest as default and save the result as a shapefile with the name contours.shp. Note that you can't save the layer into an existing GeoPackage.
6. Click Run. Click Close after processing.
Let's style the calculated contour lines in the same way as the rendered lines.
Therefore we need to add an attribute for the index lines.
7. Go to the attribute table of the contours layer.
8. Toggle to editing mode and open the Field Calculator.
9. Create a new field with the name Index, which has an Output field type of Whole number (Integer) and an Output field length of 1.
10. Create the following expression:
if( "Z" % 25 = 0, 1, NULL )
The expression uses the modulo (%) operator, which returns the remainder of a division. So in this case we divide the value in the Z field by 25. If there's no remainder, we give it value 1, else the Index field gets NULL (which means no data).
11. Click OK and check the result in the attribute table.
12. Toggle off editing mode and close the attribute table.
13. Make sure that the rendered Contourlines layer is hidden and go to the Layer Styling panel to style the contours vector layer.
14. Choose the Categorized renderer and select the Index field from the drop down list at Value.
15. Click Classify.
16. Click on the symbol of 1 and make it black. Click on the symbol of all other values and make it gray.
The result now looks like this:
Let's add some labels.
17. In the
Layer Styling panel go to the
Labels tab.
18. Choose Single Labels and Z for the Value field.
19. Go to the Placement
tab. Change the
Mode to
Curved, check the
On line box and uncheck the
Above line box.
20. In the Repeating Labels section, change the Distance to 150 mm. This will allow multiple labels on long lines, making it easier for the reader to find its height.
21. Go to the
Buffer tab. Check the box to
Draw text buffer and set it to 0.5 mm. This makes the labels more readable through the contour lines.
The map should now look like this:
Note that in the Processing Toolbox there are two tools for contours:
The Contour tool is the same as used in this exercise and generates lines. The second tool creates polygons instead of lines.
With these results you can now create a nice map in the Print Layout.