šŸ”ļøQGISBeginnerā±ļø 3 mins read

Raster Data & Digital Elevation Models (DEM)

Published by GISTECHNEWS Editorial Team • Peer-Reviewed & Verified on QGIS 3.34+ LTR & Python 3.10+

While vector data models real-world boundaries with distinct geometry, many geographic phenomena vary continuously across space: surface elevation, air temperature, atmospheric aerosol optical depth, and multispectral reflectance. These continuous fields are represented using the Raster Data Model. A raster is a regular two-dimensional matrix of square cells (pixels) organized into rows and columns, where each cell stores a single quantitative or qualitative value. In this tutorial, we analyze the spatial mechanics of rasters, ground sample distance (GSD), affine geotransforms, and the critical role of Digital Elevation Models (DEMs) in GIS.

šŸ“‹ Prerequisites

  • QGIS 3.34+ LTR installed.
  • Basic understanding of coordinates and digital image grids.
  • Sample elevation raster (e.g., SRTM or ALOS DEM GeoTIFF).

šŸ› ļø Technical Environment

Required Software: QGIS / GDAL (Recommended: 3.34+ LTR)

Practice Dataset: SRTM 30m Digital Elevation Model

Source Portal: NASA Earthdata / USGS

CRS / Format: WGS 84 (EPSG:4326) (GeoTIFF (.tif))

Step-by-Step Workflow & Methodological Execution

1

Module 1: Raster Geometry & The Affine Geotransform

Unlike a vector shape where every vertex stores explicit geographic coordinates, a raster file only stores: 1. Origin Coordinates [X_origin, Y_origin]: The geographic coordinate of the upper-left corner pixel. 2. Pixel Dimensions [Pixel_Width, Pixel_Height]: The physical ground distance covered by a single cell (Ground Sample Distance). For example, a 30m SRTM DEM has pixel dimensions of 30 meters. 3. Rotation Coefficients: Usually zero unless the image is skewed. This 6-parameter matrix is known as the Affine Geotransform. The GIS computes the real-world coordinate of any arbitrary pixel (column $c$, row $r$) mathematically: $$X = X_{origin} + c \times Pixel\_Width$$ $$Y = Y_{origin} + r \times Pixel\_Height$$ This allows multi-gigabyte raster grids to be mapped across millions of pixels without storing redundant coordinates for every single cell.

2

Module 2: DEM vs DTM vs DSM Explained

Elevation models are often referred to interchangeably, but they represent fundamentally distinct physical surfaces: • Digital Surface Model (DSM): Captures the elevation of the highest physical surfaces on Earth, including tree canopies, building rooftops, powerlines, and infrastructure. Raw photogrammetric point clouds create DSMs. • Digital Terrain Model (DTM): Represents the bare-earth terrain surface, with all natural and human-built features (trees, vegetation, structures) algorithmically removed. • Digital Elevation Model (DEM): A generic umbrella term encompassing both DSM and DTM representations, commonly stored as single-band floating-point rasters where cell values represent elevation in meters above Mean Sea Level (MSL).

3

Module 3: Bit-Depth, Radiometry, and NoData Masks

Rasters store cell values according to strict numerical data types: • 8-bit Unsigned Integer (Byte): Stores integer values from 0 to 255. Ideal for land-cover classification codes or standard RGB web images. • 16-bit Signed Integer (Int16): Stores values from -32,768 to +32,767. Widely used for global elevation models (SRTM) where elevations can dip below sea level. • 32-bit Floating Point (Float32): Stores decimal values (e.g., elevation 1420.85m or NDVI 0.642). Necessary for continuous scientific modeling. NoData Values: In every satellite or elevation dataset, edge areas exist where no measurement was taken. A special flag (such as -9999 or NaN) is assigned as the NoData value. QGIS treats these pixels as 100% transparent and excludes them from mathematical and statistical calculations.

āš ļø Common Errors & Troubleshooting

āŒ Raster renders as solid black or white

šŸ’” Resolution: Open Layer Properties -> Symbology -> change Min/Max values to 'Cumulative Count Cut (2% - 98%)'.

āŒ Black border around warped DEM raster

šŸ’” Resolution: Set 'NoData value' to 0 or -9999 in Layer Properties -> Transparency.

šŸ’” Expert Tips & Best Practices

  • Build raster pyramid overviews (.ovr) using GDAL to ensure smooth zoom performance on multi-gigabyte raster tiles.
  • Always verify pixel size units; in EPSG:4326 pixel size is in decimal degrees (~0.000277° = 30m at equator).

šŸ Python Rasterio & NumPy DEM Processing

import rasterio
import numpy as np

# Open a Digital Elevation Model (GeoTIFF)
with rasterio.open("elevation_dem.tif") as src:
    dem = src.read(1) # Read band 1
    nodata = src.nodata
    transform = src.transform
    crs = src.crs

# Mask out NoData pixels
valid_dem = np.ma.masked_equal(dem, nodata)

print(f"DEM Resolution: {abs(transform[0]):.2f}m x {abs(transform[4]):.2f}m")
print(f"Spatial Extent CRS: {crs}")
print(f"Minimum Elevation: {valid_dem.min():.1f} meters")
print(f"Maximum Elevation: {valid_dem.max():.1f} meters")
print(f"Mean Elevation: {valid_dem.mean():.1f} meters")

šŸ”— Related Tutorials & Practical Workflows