Introduction to Raster Data Part 2: DEMs and Raster Calculator
Credit: Youtube Channel “Statistics Canada”
Raster data continues to be one of the fundamental building blocks of geographic information systems. In this second part of our introduction to raster data series, we’ll explore Digital Elevation Models (DEMs) and learn how to harness the power of QGIS’s Raster Calculator for advanced spatial analysis.
Understanding Digital Elevation Models (DEMs)
A Digital Elevation Model is a gridded array of elevations that represents the bare-earth terrain. DEMs are crucial for terrain analysis, hydrological modeling, urban planning, and countless other GIS applications. These raster datasets store elevation values as cell values, creating a three-dimensional representation of the Earth’s surface.
Types of Elevation Data
- DTM (Digital Terrain Model): Represents the bare earth surface without vegetation and buildings
- DSM (Digital Surface Model): Includes all surface features like buildings and vegetation
- DEM (Digital Elevation Model): Generic term often used interchangeably with DTM
Acquiring DEM Data
Several sources provide free DEM data for various scales and resolutions:
- USGS National Map (30m, 10m, and LiDAR-derived)
- NASA SRTM (30m global coverage)
- Copernicus DEM (30m global)
- ASTER GDEM (30m global)
Working with DEMs in QGIS
QGIS provides robust tools for working with elevation data. Start by loading your DEM into QGIS through Layer > Add Layer > Add Raster Layer. Once loaded, you can visualize elevation variations using different color ramps and styling options.
Basic DEM Visualization
- Right-click on your DEM layer and select “Properties”
- Navigate to the “Symbology” tab
- Change the render type to “Singleband pseudocolor”
- Select an appropriate color ramp (e.g., terrain colors)
- Modify the min/max values to enhance contrast
Introduction to Raster Calculator
The Raster Calculator in QGIS is a powerful tool that allows you to perform mathematical operations on raster datasets. Found under Raster > Raster Calculator, this tool enables complex spatial analysis by combining mathematical operations with geographic data.
Accessing Raster Calculator
Navigate to Raster > Raster Calculator in the main menu, or use the Processing Toolbox to find the native version which offers additional functionality.
Raster Calculator Interface
The interface consists of several key components:
- Expression box: Where you build your mathematical expressions
- Raster bands list: Available raster layers for analysis
- Operators panel: Mathematical and logical operators
- Output settings: Define output location and format
Practical Examples with DEMs and Raster Calculator
Creating Slope Maps
While QGIS has dedicated slope tools, you can also calculate slope using the Raster Calculator with the formula:
("elevation@1" * 0) + (sqrt("elevation@1" * "elevation@1"))
However, it’s more practical to use the native Slope algorithm found in the Processing Toolbox.
Elevation Classifications
Create elevation zones using conditional statements:
("dem@1" <= 500) * 1 + (("dem@1" > 500) AND ("dem@1" <= 1000)) * 2 + ("dem@1" > 1000) * 3
Viewshed Analysis Preparation
Prepare DEM data for viewshed analysis by applying mathematical transformations:
("dem@1" - minimum("dem@1")) / (maximum("dem@1") - minimum("dem@1")) * 100
Advanced Raster Calculations
Multi-Raster Operations
Combine multiple raster datasets for comprehensive analysis:
("temperature@1" * "precipitation@1") / ("elevation@1" + 1)
Conditional Logic
Use conditional operators for complex classifications:
if("dem@1" < 200, 1, if("dem@1" < 500, 2, 3))
Mathematical Functions
Apply mathematical functions for data transformation:
sqrt("dem@1") + log("population@1" + 1)
Performance Considerations
When working with large raster datasets, consider these optimization tips:
- Use appropriate data formats (GeoTIFF with compression)
- Clip datasets to your area of interest
- Use lower resolution datasets for preliminary analysis
- Ensure adequate system memory for processing
Quality Control and Validation
Always validate your raster calculations:
- Check value ranges using Layer Properties > Information
- Visualize outputs to identify anomalies
- Compare results with known reference data
- Document all processing steps for reproducibility
FAQ
What is the difference between DEM, DTM, and DSM?
DEM is a general term for digital elevation models. DTM represents bare earth surface without features like buildings, while DSM includes all surface features including vegetation and structures. DTM is typically created from DSM through feature removal.
How do I improve DEM visualization in QGIS?
Use the "Hillshade" tool to create realistic terrain effects. Apply multiple color ramps, adjust contrast and brightness, and overlay hillshade as a semi-transparent layer. Experiment with different symbology options in the Layer Properties dialog.
What are common Raster Calculator errors?
Common errors include mismatched raster extents and resolutions, division by zero, invalid syntax in expressions, and insufficient memory for processing. Always ensure input rasters align spatially and check expression syntax carefully.
Can I use Raster Calculator with different coordinate systems?
It's recommended to use rasters in the same coordinate system. While QGIS can handle some reprojection on-the-fly, it's best practice to reproject datasets before analysis for consistent results and optimal performance.
How do I optimize large raster calculations?
Clip rasters to your exact area of interest, use appropriate resolution, consider processing in chunks, and ensure adequate system resources. Monitor progress using the Log Messages panel and save intermediate results to avoid rebuilding calculations.
What file formats work best with Raster Calculator?
GeoTIFF is the most reliable format for QGIS raster operations. Consider using compression (LZW or DEFLATE) to reduce file sizes. Avoid proprietary formats when possible and always keep backups of original data.