





















































In this article by Alexander Bruy, author of the book, QGIS 2 Cookbook, we will see some of the most common operations related to Digital Elevation Models (DEM).
(For more resources related to this topic, see here.)
A hillshade layer is commonly used to enhance the appearance of a map, and it can be computed from a DEM. This recipe shows how to compute it.
Open the dem_to_prepare.tif layer. This layer contains a DEM in EPSG:4326 CRS and elevation data in feet. These characteristics are unsuitable to runmost terrain analysis algorithms, so we will modify this layer to get a suitable algorithm.
Leave the rest of the parameters with their default values.
The hillshade layer will be added to the QGIS project, as shown in the following screenshot:
As in the case of the slope, the algorithm is part of the GDAL library. You will see that the parameters are quite similar to the slope case. This is because the slope is used to compute the hillshade layer. Based on the slope and the aspect of the terrain in each cell, and using the position of the sun defined by the Azimuth and Altitude fields, the algorithm computes the illumination that the cell will receive.
You can try changing the values of these parameters to alter the appearance of the layer.
As in the case of slope, there are alternative options to compute the hillshade. The SAGA one in the Processing toolbox has a feature that is worth mentioning.
The SAGA hillshade algorithm contains a field named method. This field is used to select the method used to compute the hillshade value, and the last method available. Raytracing, differs from the other ones. In that it models the real behavior of light, making an analysis that is not local but that uses the full information of the DEM instead. This renders more precise hillshade layers, but the processing time can be notably larger.
You can combine the hillshade layer with your other layers to enhance their appearance.
Since you have used a DEM to compute the hillshade layer, it should be already in your QGIS project along with the hillshade itself. However, it will be covered by it since the new layers are produced by the processing. Move it to the top of the layer list, so you can see the DEM (and not the hillshade layer) and style it to something like the following screenshot:
In the Properties dialog of the layer, move to the Transparency section and set the Global transparency value to 50 %, as shown in the following screenshot:
Now you should see the hillshade layer through the DEM, and the combination of both of them will look like the following screenshot:
A common analysis from a DEM is to compute hydrological elements, such as the channel network or the set of watersheds. This recipe shows the steps to follow to do it.
Open the DEM that we prepared in the previous recipe.
Starting from the DEM, the preceding described steps follow a typical workflow for hydrological analysis:
The key parameter in the preceding workflow is the catchment area threshold. If a larger threshold is used, fewer cells will be considered as river cells, and the resulting channel network will be sparser. Because the watersheds are computed based on the channel network, it will result in a lower number of watersheds.
You can try yourself with different values of the catchment area threshold. Here, you can see the result for threshold equal to 10,00,000 and 5,00,00,000. The following screenshot shows the result of threshold equal to 10,00,000:
The following screenshot shows the result of threshold equal to 5,00,00,000:
Note that in the previous case, with a higher threshold value, there is only one single watershed in the resulting layer.
The threshold values are expressed in the units of the catchment area, which, because the cell size is assumed to be in meters, are in square meters.
Because the topography defines and influences most of the processes that take place in a given terrain, the DEM can be used to extract many different parameters that give us information about those processes. This recipe shows to calculate a popular one named the Topographic Wetness Index, which estimates the soil wetness based on the topography.
Open the DEM that we prepared in the Calculating a hillshade layer recipe.
The index combines slope and catchment area, two parameters that influence the soil wetness. If the catchment area value is high, it means more water will flow into the cell thus increasing its soil wetness. A low value of slope will have a similar effect because the water that flows into the cell will not flow out of it quickly.
The algorithm expects the slope to be expressed in radians. That's the reason why the Slope, Aspect, and Curvature algorithm has to be used because it produces its slope output in radians. The Slope algorithm that you will also find, which is based on the GDAL library, creates a slope layer with values expressed in degrees. You can use that layer if you convert its units by using the raster calculator.
Other indices based on the same input layers can be found in different algorithm in the Processing toolbox. The Stream Power Index and the LS factor fields use the slope and catchment area as inputs as well and can be related to potential erosion.
In this article, we saw the working of the hillshade layer and a topographic index along with their calculation technique. We also saw how to analyze hydrology.
Further resources on this subject: