Project

Last updated on 2025-03-13 | Edit this page

Estimated time: 12 minutes

Overview

Questions

  • What is DEM?
  • What types of downstream information can be derived from a DEM?
  • What is the topographic landscape around Purdue?
  • What are the hydrological features around Purdue?

Objectives

  • Define and explain the preliminary knowledge.
  • Show how to install plugins with QGIS.
  • Identify the types of downstream information that can be derived from a DEM.
  • Demonstrate how to analyze topographic landscape and hydrological features with QGIS.
  • Explain the process of converting raster data to vector data.
  • Demonstrate how to run multiple instances in one shot.

Preliminary Knowledge


Knowledge Graph
Knowledge Graph

1. DEM (Digital Elevation Model):

A DEM is essentially a 3D representation of a terrain’s surface. It’s a raster dataset, meaning it’s made up of a grid of cells (pixels), where each cell contains an elevation value.

  • Think of it as a digital map that shows the height of the land at every point.
  • DEMs are the foundation for creating slope, hillshade maps and analyzing hydrology.
  • The DEM we used today is LiDAR (Light Detection and Ranging) data with one meter resolution from USGS, which uses laser pulses from aircraft or drones to measure terrain elevation accurately.

2. Slope:

Slope refers to the steepness or gradient of the terrain. It’s typically expressed in degrees (0 to 90) or as a percentage. A slope of 0 degrees indicates a flat surface, while a slope of 90 degrees represents a vertical surface.

Slope maps are derived from DEMs and are useful for analyzing things like:

  • Erosion risk
  • Water runoff
  • Suitability for construction

3. Hillshade:

Hillshade refers to simulating how sunlight would illuminate the terrain. It enhances the visualization of landforms by showing how light and shadow interact with the surface. The hillshade effect is created by setting an azimuth and vertical angle for a light source. The Azimuth is the direction the light is coming from, and the vertical angle is the angle of the light source above the horizon.

Hillshade maps are also derived from DEMs and are valuable for:

  • Visualizing terrain features and creating visually appealing maps
  • Identifying subtle topographic details

4. Analyzing hydrology

The workflow: DEM Input → Fill Sinks → Flow Direction → Flow Accumulation → Stream Extraction -> Subbasins

  • Before calculating flow, the DEM needs to be preprocessed to remove any small depressions (sinks) that may trap water. These are often errors in the data or natural terrain features that disrupt continuous flow.
  • The flow direction represents the direction in which water will move from each cell based on elevation. The most common method assigns flow using the D8 algorithm, where water moves to the steepest downward slope among the eight neighboring cells.
  • The flow accumulation raster represents the number of upstream cells contributing flow to each cell. This helps identify areas with higher accumulated flow, which can indicate potential stream paths.
    • Low accumulation values: Represent hilltops or ridges.
    • High accumulation values: Represent valleys or stream networks.
  • Streams are extracted by applying a threshold to the flow accumulation raster. A threshold defines the minimum number of contributing cells required to form a stream.
    • Higher thresholds result in fewer, larger streams.
    • Lower thresholds detect smaller streams, but may introduce noise.
  • Last step is to extract Watersheds/Subbasins, an area of land that drains all precipitation and surface runoff to a common outlet(such as a river, lake, or ocean).
    • It is defined by topographic divides (ridges or hills) that separate it from adjacent watersheds.

    • Watersheds can be small (for example, a stream watershed) or large (covering multiple rivers).

    • Same concept as Catchments and Basins, but they are in different scales:

      Basin → contains multiple → Sub-Basins → made up of → Watersheds → includes smaller → Catchments

5. Wetness Index

The Wetness Index, often referred to as the Topographic Wetness Index (TWI), is a terrain attribute that quantifies the propensity of a location to accumulate water. It’s a crucial tool in hydrological and ecological modeling, providing insights into soil moisture, runoff potential, and habitat distribution.

  • The TWI is based on the principle that areas with a large upslope contributing area and a shallow slope are more likely to accumulate water.

  • It combines information about the upslope contributing area (the area that drains into a given point) and the slope gradient.

  • \(TWI = ln(\dfrac{\alpha}{tan\beta})\)

    where \(\alpha\) is specific catchment area (i.e. the upslope contributing area per unit contour length), \(\beta\) is the local slope angle.

Load Data

Let’s first load the two rasters in data directory.

Screenshot 2025-03-04 at 2 21 14 PM

Install Plugins


Install QuickMapServices

QuickMapServices (QMS) is a valuable plugin for QGIS that simplifies the process of adding and using a vast array of online basemaps and web mapping services.

  • Go to Plugins -> Manage and Install Plugins
  • Search “QuickMapSevices” and click “Install Plugin”
  • Now click “Search QMS” and search “Google Maps”, as below.
Screenshot 2025-03-04 at 12 11 27 PM
Screenshot 2025-03-04 at 12 11 54 PM
Picture6

Install WhiteboxTools

WhiteboxTools is a powerful, open-source geospatial data analysis platform that offers a wide range of geospatial analysis tasks including DEM analysis, hydrological modeling and more.

  • Step 1: Install WhiteboxTools for QGIS

    • go to Plugins -> Manage and Install Plugins
    • search “WhiteboxTools for QGIS” and click “Install Plugin”
  • Step 2: Install Whitebox Executables

    • option 1: go to WhiteboxTools and download.
    • option 2: run the command below:

    SH

    wget https://www.whiteboxgeo.com/WBT_Linux/WhiteboxTools_linux_amd64.zip
  • Step 3: Unzip it by running

    SH

    unzip WhiteboxTools_linux_amd64.zip
  • Step 4: Configurate it

    • go to Settings -> options -> Processing -> providers -> WhiteboxTools

    • go to WhiteboxTools executable and double click the content and click “…” to set it as “whitebox_tools” in your unzipped directory(the executable).

      your executable should be as below (you can also copy and paste):

      SH

      /home/trainXX/WhiteboxTools_linux_amd64/WBT/whitebox_tools
      Screenshot 2025-03-04 at 11 57 25 AM
  • Step 5: Now you could see WhiteboxTools show up at the bottom of the Processing Toolbox as below.

    Screenshot 2025-03-04 at 12 07 08 PM

Merge DEM Data


  • Search “merge” in Processing Toolbox as below

    image
  • Select the two rasters as input

image
  • Type the output name in your scratch directory and hit “Run”.
Output file will be added to layers if you check “Open outputfile after running algorithm”
Output file will be added to layers if you check “Open outputfile after running algorithm”
  • Now you could merged DEM in your Layers as below
image

Calculate Slope


Search “Slope” in Processing Toolbox, select the elevation layer, type the output file, and hit “Run” as below.

Callout

Spend two minutes to explore the slope where your are familar and see if it makes sense. For example, I used it to find a nice slope to snow sled.

image

Calculate Hillshade


Search “Hillshade” in Processing Toolbox, and input the elevation layer, parameters, and output as the figure below.

We use the default settings here that typically place the light source in the northwest. It is a common convention in cartography for visualizing topography. (Vertical Views | GEOG 486: Cartography and Visualization, n.d.)

Analyze Hydrology


(1) Fill Sinks

  • Step 1: type a few words to search “FillDepressionsWangAndLiu” as below

  • Step 2: select dem, type output file, and hit “Run”

  • Step 3: hit close after the progress reach 100%, as below

(2) Flow Direction

  • Step 1: search “d8” to find “D8Pointer” in the Processing Toolbox.
  • Step 2: select “fillsinks” outputed from above procedure as the input DEM file and type the output as below
  • Step 3: hit close after the progress reach 100%; you will see the flowdirection layer has been added to Layers.

(3) Flow Accumulation

  • Step 1: type a few words to search “D8FlowAccumulation” in the Processing Toolbox.
  • Step 2: select “flowdirec” outputed from above procedure as the input and type output
check “Is input the D8 flow pointer”
check “Is input the D8 flow pointer”
  • Step 3: hit close after the progress reach 100%; you will see the flowaccum layer has been added to Layers.

(4) Extract Streams

  • Step 1: search “ExtractStreams” in the Processing Toolbox.

  • Step 2: select “flowaccum” outputed from above procedure as the input and type output, set the Channelization Threshold as 1,000,000 as below

  • Step 3: hit close after the progress reach 100%; you will see the stream10_6 layer has been added to Layers.

Callout

To better see the streams, you could uncheck other layers except the google map layer, and zoom in to compare the generated streams with the ones on the map.

Let’s convert it to vector: Go to Raster -> Conversion -> Polygonize (Raster to Vector), as below

you can choose different file format of vector
you can choose different file format of vector

Try different Channelization Threshold and compared the extracted streams.

(5) Watershed

  • Step 1: search “Subbasins” in the Processing Toolbox.
  • Step 2: select “flowdirect” as the D8 Pointer File, stream10_6 as the InputStreams File and type output, as below

Callout

  • You could also click “Run as Batch Process” and run multiple instances in one shot, as below

All algorithms (including models) can be executed as a batch process. That is, they can be executed using not just a single set of inputs, but several of them, executing the algorithm as many times as needed. This is useful when processing large amounts of data, since it is not necessary to launch the algorithm many times from the toolbox.

Calculate Topographic Wetness Index


  • Step 1: search “WetnessIndex” in the Processing Toolbox.

  • Step 2: select “subbasins10_6” calculated from the above procedure as the SCA File, slope as the Input Slope File and type output, as below

  • Step 3: After the calculation finishs, right click the output Layer, and select “Properties” and set as below

Output

the smaller Channelization Threshold is, the more channels you generated, and the high resolution you got (As below shows more accurate Wetness Index, with Channelization Threshold, 1000)

Key Points

  • DEMs are the foundation for creating slope, hillshade maps and analyzing hydrology.
  • Install plugins with QGIS, for example, QuickMapServices (QMS) offers a variety of base maps and WhiteboxTools offers a wide range of geospatial analysis tasks.
  • Demonstrate how to analyze topographic landscape and hydrological features with QGIS.
  • We can choose different file format to vectorize raster data.
  • “Run as Batch Process” can run multiple instances in one shot.