Tutorial: Calculate the Topographic Wetness Index from a DTM
Site: | OpenCourseWare for GIS |
Course: | QGIS Advanced Tutorials |
Book: | Tutorial: Calculate the Topographic Wetness Index from a DTM |
Printed by: | Guest user |
Date: | Thursday, 21 November 2024, 5:25 PM |
1. Introduction
The Topographic Wetness Index (TWI) is a useful model to estimate where water will accumulate in an area with elevation differences. It is a function of slope and the upstream contributing area:
TWI =
Where:
a = uplope contributing area (m2)
b = slope in radians.
In this tutorial we're going to implement this equation in QGIS. The input data is a DTM.
After this tutorial you'll be able to:
- Interpolate voids in a DTM
- Calculate slope in degrees
- Convert slope from degrees to radians
- Calculate TWI
2. Interpolate Voids in the DTM
The provided DTM is derived from LIDAR data from the Netherlands (AHN3). The data in the Dutch Amersfoort projection (EPSG: 28992). The DTM, however, has voids. Voids are pixels with nodata. These voids need to be interpolated before we can continue.
1. Start QGIS.
2. Add the provided DTM (dtm.tif) to a blank project.
You can clearly see the voids.
3. Go to the Processing Toolbox: in the main menu choose Processing | Toolbox.
4. In the Processing Toolbox select GDAL | Fill nodata.
5. In the Fill nodata dialogue choose dtm as Input layer. Keep other settings as default (you can play with these if the voids are bigger). Save the result as dtm_voidfilled.tif.
6. Click Run. Close the dialogue after processing.
7. Remove the dtm layer from the Layers panel.
In the result you can clearly see that the voids have been interpolated.
8. Style the DTM with Singleband Pseudocolor. You can use a Topography ramp from the cpt-city catalogue. Blend the DTM with the hillshade (see other tutorials on how to do this).
Now the DTM is ready we can proceed with calculating the slope.
Note that in QGIS 3.14 you need to set the projection of the raster layer after each calculation. This is not the case in the 3.10 LTR versions.
3. Calculate Slope in Degrees and in Radians
( "slopedegrees@1" <= 0 ) * 1 + ( "slopedegrees@1" > 0 ) * "slopedegrees@1"
"slopedegrees_modified@1" * 0.01745
4. Calculate the Contributing Upslope Area
In this section we're going to calculate the contributing upslope area for each pixel in the DTM.
1. Go to the Processign Toolbox and choose SAGA | Simulation | Flow accumulation (qm of esp).
2. In the dialogue choose dtm_voidfilled as DEM, keep the default Preprocessing to fill sinks temporarily and save the Contributing Area to contributing_upslope_area.sdat.
3. Click Run. Close the dialogue after processing.
The result is for each pixel the amount of pixels that are upstream.
Now we're ready to calcute TWI.
5. Calculate TWI
Now we have the slope in radians and the upslope contributing area (in pixels) we can calculate the Topographic Wetness Index in the Raster Calculator.
1. Go to the Raster Calculator.
2. Write the following equation:
ln ( ( "contributing_upslope_area@1" * 5 * 5 ) / tan ( "sloperadians@1" ) )
6. Visualise TWI in the 3D view
We can further inspect the results in the 3D view.
1. In the main menu choose: View | New 3D Map View.
2. Configure the scene by clicking
3. Set the Terrain Type to DEM (Raster Layer) and choose dtm_voidfilled layer for Elevation. Use a Vertical scale of 3 to exaggerate the terrain.
4. Click OK and inspect the result.