gdaldem
Create Digital Elevation Model (DEM) visualizations
TLDR
Compute the hillshade of a DEM
Compute the slope of a DEM
Compute the aspect of a DEM
SYNOPSIS
gdaldem <mode> <input_dem> <output_raster> [options]
PARAMETERS
<mode>
The operation to perform. Common modes include hillshade, slope, aspect, color-relief, tpi, tri, roughness.
<input_dem>
The path to the input Digital Elevation Model raster file.
<output_raster>
The path to the output raster file that will be generated.
-of <format>
Selects the output format driver. E.g., -of GTiff.
-b <band>
Selects the input band to use from the DEM (default is 1).
-s <scale>
Scale factor for vertical units relative to horizontal units. Default is 1.0. Useful for units conversion (e.g., feet to meters).
-z <zfactor>
Vertical exaggeration factor. Useful for making terrain relief more prominent in hillshades.
-alg <algorithm>
Specifies the algorithm for slope/aspect computation. E.g., -alg ZevenbergenThorne.
-compute_edges
Computes values for edge pixels which might be nodata by default due to filter size.
-co <NAME=VALUE>
Passes creation options to the output format driver. E.g., -co COMPRESS=LZW.
-q
Quiet mode; suppresses progress messages.
-md <value>
Nodata value for the output raster.
-az <azimuth>
(For hillshade) Azimuth of the sun in degrees (0-360, 0 is North). Default is 315.
-alt <altitude>
(For hillshade) Altitude of the sun in degrees (0-90, 90 is directly overhead). Default is 45.
-combined
(For hillshade) Produces a combined hillshade and slope output (grayscale).
-multidirectional
(For hillshade) Generates a multidirectional hillshade (more natural appearance).
-p
(For slope) Output slope in percent instead of degrees.
-zero_for_flat
(For aspect) Sets aspect of flat areas (slope 0) to 0 instead of nodata.
-color-text-file <file>
(For color-relief) Path to a text file defining color ramps.
-alpha
(For color-relief) Adds an alpha band to the output, allowing transparency.
-clip <min_val> <max_val>
(For color-relief) Clips the elevation range used for color-relief.
-nearest_color_entry
(For color-relief) Uses the nearest color entry from the color file instead of interpolation.
-denom <factor>
(For tpi, tri, roughness) Denominator for output values (e.g., -denom 100 to output values in meters/feet instead of cm/inches).
DESCRIPTION
gdaldem is a versatile command-line utility from the GDAL (Geospatial Data Abstraction Library) suite designed for processing Digital Elevation Models (DEMs). It can generate various derived products from a DEM, such as hillshade images, slope maps (in degrees or percent), aspect maps (direction of slope), color relief visualizations, and terrain analysis products like Topographic Position Index (TPI), Terrain Ruggedness Index (TRI), and Roughness.
It supports a wide range of raster formats for both input and output, leveraging GDAL's extensive format drivers. Users can customize the output using numerous options, including scaling factors, vertical exaggeration, illumination parameters for hillshades, and specific algorithms for slope and aspect calculations. This tool is fundamental for geospatial analysis, cartography, and environmental modeling, allowing users to transform raw elevation data into more interpretable and analytically useful representations.
CAVEATS
- gdaldem assumes input DEM is projected correctly. Issues can arise if geographic (lat/long) coordinates are used without appropriate scaling (-s).
- The -compute_edges option can be computationally intensive, especially for large datasets or large filter windows (for tpi, tri, roughness).
- Output resolutions and extents are typically derived directly from the input DEM. For custom outputs, gdal_translate or gdalwarp might be needed post-processing.
DEM PROCESSING MODES
gdaldem supports several distinct processing modes, each designed for a specific terrain analysis task. These include:
- hillshade: Generates a shaded relief map based on illumination parameters.
- slope: Calculates the steepness of the terrain.
- aspect: Determines the directional orientation of the slope.
- color-relief: Creates a color-coded representation of elevation, often using a specified color ramp file.
- tpi (Topographic Position Index): Compares the elevation of a central pixel to the mean elevation of its neighborhood.
- tri (Terrain Ruggedness Index): Quantifies terrain ruggedness by summarizing elevation differences between a central pixel and its neighbors.
- roughness: Similar to TRI, measures the local variation in elevation.
HISTORY
gdaldem has been an integral part of the GDAL utility suite since its inception, evolving with the library itself. It leverages GDAL's robust raster I/O capabilities and has seen continuous improvements in algorithms, performance, and supported options. Its development reflects the growing need for specialized terrain analysis tools directly accessible from the command line, making it a staple for automated geospatial workflows and scripting.
SEE ALSO
gdal_translate(1), gdalwarp(1), gdalinfo(1), ogrinfo(1)