Hydrological & Terrain Analysis using WhiteboxTools
Contents
Introduction
This tutorial demonstrates how to perform hydrological and terrain analysis within QGIS. The workflow begins with downloading a DEM dataset, installing WhiteboxTools, and configuring QGIS to recognize the WhiteboxTools functions. Subsequent steps includes DEM preprocessing, flow direction and flow accumulation modelling, deriving slope and the creation of a Topographic Wetness Index (TWI) map.
Data & Software Requirements
- 30 m DEM of the Kananaskis region
- QGIS
- WhiteboxTools Open Core
Step 0: Installing WhiteboxTools
Download WhiteboxTools
To download WhiteboxTools, head on over to the WhiteboxTools Download Page and download the WhiteboxTools Open Core. After downloading, extract the .zip file and place the folder somewhere easy to find. For example, you may store it in: C:\Program Files\WhiteboxTools\
Configuring WhiteboxTools in QGIS
In QGIS, open Plugins → Manage and Install Plugins. In the search bar, type "WhiteboxTools" and the plugin should appear in the list. Select it and click "Install Plugin".
To configure the path to the WhiteboxTools executable, open Settings → Options → Processing. In the dialogue window, open Providers → WhiteboxTools, and under "WhiteboxTools executable", browse to the folder where you extracted the files and select the file named "whitebox_tools" which is found inside the WBT folder.
Once configured, WhiteboxTools tools will appear in the QGIS Processing Toolbox.
Step 0.5: Downloading the DEM
The digital elevation model (DEM) used in this tutorial is the Copernicus GLO-30 Digital Elevation Model, downloaded through the OpenTopography portal.
Feel free to use your own DEM, but if you wish to follow the tutorial with the exact dataset shown here, go to the Copernicus GLO-30 Digital Elevation Model.
On the OpenTopography page, scroll down to the "Coordinates" section, check off "Manually enter selection coordinates", and enter the following:
Xmin = -115.44776916503906
Ymin = 50.68473994828557
Xmax = -115.0165557861328
Ymin = 51.03926216055825
Before submitting the request, ensure the output format is set to "GeoTiff".
Step 1: Importing the DEM into QGIS & Preparing Your Workspace
Once your DEM has been downloaded, the first step is to load it into QGIS.
You can add the DEM to QGIS by going to Layer → Add Layer → Add Raster Layer. Navigate to your downloaded DEM in the dialogue window and click "Add".
The DEM should now appear as a grayscale raster in the QGIS map window. It should look something like this:
Make sure to rename the DEM layer as well. Meaningful layer names are crucial for an organized workflow, especially in hydrological and/or terrain analysis where many output rasters are generated. Renaming the DEM ensures all subsequent outputs are easy to identify and prevents confusion when selecting inputs for WhiteboxTools tools.
To rename the layer, right click the DEM in the Layers panel and click on "Rename Layer". Choose a meaning full name, such as: "kananaskis_rawDEM".
Before moving on to the next step, ensure you have saved your QGIS project.
Step 2: Preprocessing
Breaching Depressions
Before running any hydrological tools, the DEM needs to be hydrologically corrected. Raw digital elevation models almost always contain small artificial depressions that happen because of noise, interpolation gaps, or missing elevation values. These depressions trap flow, which prevents tools like D8Pointer and D8FlowAccumulation, both used in subsequent steps, from producing a proper drainage network.
To fix this, we use BreachDepressions in WhiteboxTools, which removes the depressions by cutting narrow channels through them so water can continue flowing downslope.
In QGIS, open the Processing Toolbox. At the bottom of the toolbox pane, expand WhiteboxTools → Hydrological Analysis → BreachDepressions.
In the dialogue window, select your DEM as the input. For this tutorial, all parameters are left at their default values. The WhiteboxTools manual explains what each parameter does but it does not require any specific modifications for general preprocessing. Since the goal here is to demonstrate the workflow rather than fine-tuning terrain modifications, the defaults are perfectly fine.
Choose a meaningful output name, such as kananaskisDEM_breached, and remember to add .tif at the end.
A quick note: WhiteboxTools also includes a FillDepressions tool. Both breaching and filling can be used for hydrological correction, but breaching tends to preserve the natural shape of the terrain better, which is helpful for mountain regions like Kananaskis.
Step 3: Hydrological Processing
Flow Direction
Once the DEM is hydrologically corrected, the next step is to calculate flow direction. This tells us the direction water would flow naturally move from every cell in the DEM.
To do this, we will use the D8Pointer tool. The D8 algorithm assigns each cell a direction based on the steepest downhill neighbour. It's simple, efficient, and is the standard method used for most hydrological workflows.
In the QGIS Processing Toolbox, go to: WhiteboxTools → Hydrological Analysis → D8Pointer.
Select your breached DEM as the input and choose a meaningful name for the output file. You may consider d8_flowdir.tif.
Leave the "Should the pointer file use the ESRI pointer scheme?" unchecked. WhiteboxTools uses its own D8 pointer scheme, which is different from the ESRI scheme. Since this tutorial does not require ESRI compatibility, the option is left unchecked. However, if your workflow later requires ESRI compatibility, you may check this option.
The output should look something like this:
The output may look a bit intense but this is normal. You won't really need to "interpret" it visually, as its main purpose is to feed into the next step.
Flow Accumulation
With flow direction calculated, the next hydrological step is to create a flow accumulation model. Flow accumulation counts how many upstream cells drain into each location, allowing us to visualize drainage density, major channels, and areas prone to runoff.
In the QGIS Processing Toolbox, go to: WhiteboxTools → Hydrological Analysis → D8FlowAccumulation.
Select your flow direction raster as the input. Make sure "Is the input raster a D8 flow pointer?" is checked, since we are using the pointer output from the previous step, and leave all other parameters at their default values. Give your output a meaningful name, such as, d8_flowaccumulation.tif.
WhiteboxTools offers three output types, but for this tutorial, we will use the default "cells" option, which represents the number of upslope contributing grid cells.
The "log-transform output" option was intentionally left unchecked. While WhiteboxTools allows the flow accumulation to be log transformed for visualization purposes, the manual explicilty states that log-transformed accumulation grids should not be used for secondary terrain indices like the Topographic Wetness Index (TWI). Since TWI is part of our workflow, we need the original accumulation values.
The output will look something like this:
After running the tool, your flow accumulation raster will probably appear almost completely black but this is normal. Flow accumulation usually span a huge range of values (1 to 790430 in this case) and because QGIS applies a simple linear min-max stretch to the raster, the extremely large values dominate the range. When this happens, most cells fall near the darker end of the scale and the drainage network becomes extremely difficult to see until the symbology is adjusted.
Optional: Improving Flow Accumulation Visualization
This step is purely for visualization so feel free to skip it if you wish.
To make the output interpretable:
1. Right click on the flow accumulation layer → Properties → Symbology
2. Change Render type to Singleband pseudocolor.
3. Choose a colour ramp. I chose "Blues."
4. Under Min / Max Value Settings, select Cumulative count cut. Selecting this removes extreme outliers from the min/max range. Since flow accumulation contains extremely large values, this option makes the drainage patterns visible by preventing those outliers from influencing the colour stretch.
In addition to these, the brightness, gamma, saturation and contrast can also be adjusted to help with visualization.
After the changes in symbology, the layer should look something like this:
Step 4: Terrain Analysis
Slope
Slope is a basic tool in terrain analysis that describes how steep each cell is. It is required later for the Topographic Wetness Index (TWI), where slope influences how easily water flows downslope. Steeper slopes encourage faster runoff, while gentler slopes promote moisture retention.
In the QGIS Processing Toolbox, go to: WhiteboxTools → Geomorphometric Tools → Slope.
[Insert]
Select your breached DEM as the input and leave the rest as default. Make sure to choose a meaningful output name, such as slope_kananaskis.tif.











