Starting from an elevation model
Terrain analysis works on a raster in which each cell holds a height. The note on elevation models explains the difference between a digital surface model (DSM), which includes buildings and trees, and a digital terrain model (DTM), which shows bare ground. The tools described here work on either, but the meaning of the result changes. A slope calculated from a DSM includes the sides of buildings and tree canopies.
Every derived layer depends on the cells around each cell. Slope looks at the eight neighbours of a cell, so errors in the elevation model spread into everything calculated from it.
Slope, aspect and hillshade
Slope is the steepness of the ground. It can be given in degrees, where 0 is flat and 90 is vertical, or as a percent, where 100 percent is a 45 degree slope. Aspect is the compass direction the slope faces, from 0 to 360 degrees, and flat cells have no aspect. Hillshade is a picture, not a measurement. It shades the surface as if lit from a chosen direction and height, usually from the north-west at 45 degrees, and it makes relief easy to see under other layers.
Units must match
Slope compares the change in height with the horizontal distance. If the heights are in metres and the horizontal units are degrees, as in a layer in EPSG:4326, the slope comes out wrong. Reproject the elevation model to a projected CRS, such as UTM, so both are in metres, or give the tool the correct conversion factor.
Contours
A contour line joins points of equal height. The interval between lines sets the level of detail. A 10 metre interval suits relief of a few hundred metres, such as Bengaluru, where heights run from about 750 to 965 metres across the area in the tutorial. Smooth a noisy elevation model before extracting contours. Smoothing the lines afterwards moves them, and then they no longer show true elevation.
Viewshed
A viewshed shows the area visible from a point. The tool draws a line of sight from the observer to every cell and marks the cell visible if no higher ground blocks the line.
Two heights matter. The observer height is how far above the ground the observer stands, for example 1.7 metres for a person or 30 metres for a tower. The target height is the height of the thing you want to see. A cell may be hidden for a person at ground level and visible for someone on a roof. Set both to match the question, and set a maximum distance so the tool does not run to the edge of the raster.
On a DSM, buildings and trees block the view, which is realistic for a city. On a DTM, they do not.
Hydrology
Hydrological analysis works out where water would flow over the surface. The steps follow one another.
- Fill sinks. A small pit in the elevation model traps water in the calculation, although the real land may drain. Filling removes these pits.
- Flow direction. Each cell is given the direction of its steepest downhill neighbour. A common method, called D8, uses the eight neighbours.
- Flow accumulation. Each cell receives the number of cells that drain through it. High values trace channels.
- Streams. Choosing a threshold on flow accumulation turns it into a stream network. A low threshold gives many small streams and a high one gives only the main channels.
- Watersheds. Given an outlet point, the watershed is every cell that drains to it.
The threshold is a choice, not a fact. A threshold of 500 cells at 30 metre resolution covers about 0.45 square kilometres.
Elevation profiles
An elevation profile is a cross-section of the ground along a line, with distance on one axis and height on the other. The tool samples the elevation model at regular steps along a line you draw.
Profiles are used to check the gradient of a road or pipeline, to see the shape of a valley, and to test a line of sight. For the last one, the straight line between two points must clear the ground in between. Choose a sampling step no finer than the cell size, since the model has no detail below that. A profile from a DSM includes buildings and trees, and the vertical scale of the chart is usually exaggerated, so state it.
Example: Bengaluru
The QGIS tutorial merges two 30 metre Copernicus DEM tiles for a 30 by 20 kilometre window of central Bengaluru, reprojects them to UTM, and derives slope, aspect, hillshade and 10 metre contours. A viewshed from a 30 metre observer point at Vidhana Soudha, with a maximum distance of 10 kilometres, shows what that point could see. Hydrology follows the five steps above using GRASS tools. A threshold of 500 cells gave about 1,400 stream segments, which is a dense network, and the watershed was drawn for an outlet with about 2,650 cells draining to it.
Why the results are approximate in a city
Urban DSMs have buildings and canopy that block flow in the model, and flat ground gives unreliable flow directions. Real drainage in a city also runs through pipes and channels that the model cannot see. Treat the streams as indicative, and compare them with a layer of mapped waterways before relying on them.
Common mistakes
- Calculating slope on an elevation model in degrees without correcting the units.
- Reading a slope from a DSM as the slope of the ground.
- Forgetting to set observer and target heights for a viewshed.
- Skipping the fill step and getting streams that stop in small pits.
- Treating a flow accumulation threshold as the true start of a stream.
- Smoothing contour lines after extraction.
Glossary
| Term | Meaning |
|---|---|
| Slope | The steepness of the ground, in degrees or percent |
| Aspect | The compass direction a slope faces |
| Hillshade | A shaded relief image that shows the terrain as if lit from one direction |
| Viewshed | The area visible from one or more observer points |
| Flow accumulation | The number of cells that drain through each cell |
| Watershed | The area that drains to a given outlet |
Practise it
The tutorial Terrain and hydrology derives each of these layers from a Copernicus DEM of Bengaluru.
Test yourself
1. Why is slope wrong for an elevation model in EPSG:4326?
Slope compares height change with horizontal distance. The heights are in metres and the horizontal units are degrees, so the ratio is meaningless. Reproject to a projected CRS first.
2. What are the two heights in a viewshed analysis?
The observer height, which is how far above the ground the viewer stands, and the target height, which is the height of what is being looked at.
3. What does a higher flow accumulation threshold do to a stream network?
It keeps only the cells with the largest drainage areas, so the network shows fewer, larger channels.

