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 [options]
PARAMETERS
hillshade
Mode: compute hillshaded relief from elevation
slope
Mode: compute slope angle from elevation
aspect
Mode: compute slope aspect (direction downhill)
color-relief
Mode: apply color ramp to elevation using text file
TRI
Mode: compute Topographic Ruggedness Index
TPI
Mode: compute Topographic Position Index
roughness
Mode: compute terrain roughness
-co "NAME=VALUE"
Raster creation options (e.g., COMPRESS=LZW)
-b
Select input band (default 1)
-z
Vertical exaggeration factor (hillshade/slope, default 1)
-s
Nominal ground resolution scale (default pixel size)
-az
Azimuth of light (hillshade, degrees, default 315)
-alt
Altitude of light (hillshade, degrees, default 45)
-alg
Slope/aspect algorithm (default ZevenbergenThorne)
-combined
Use multidirectional hillshade combination
-multidirectional
Multi-directional hillshade
-p
Slope output in percent rise (default degrees)
-zero_for_flat
Return 0 for flat areas in aspect
color_file (for color-relief)
Text file mapping elevation to RGB
-alpha
Add alpha band for transparency (color-relief)
-compute_edges
Force computation at edges
-q
Quiet mode, suppress progress
-trigonometric
Aspect in trigonometric convention (0-360)
-ig
Ignore NoData on input
DESCRIPTION
gdaldem is a versatile command-line utility from the GDAL (Geospatial Data Abstraction Library) suite, designed for processing Digital Elevation Models (DEMs) and other raster elevation data. It supports multiple modes to generate derived products essential for GIS analysis and cartography, including hillshade (simulated terrain shading), slope (terrain gradient), aspect (slope orientation), color-relief (elevation-colored maps), Topographic Ruggedness Index (TRI), Topographic Position Index (TPI), and roughness.
These operations enable quick visualization of terrain features, such as highlighting ridges, valleys, and steep areas. The tool processes large raster datasets efficiently, preserving geospatial metadata like projection and geotransform. Outputs are typically in formats like GeoTIFF, PNG, or JPEG, with customizable creation options. Mode-specific parameters adjust computations, e.g., scaling factors for accurate slope in different units or lighting angles for realistic hillshading.
Common workflows involve feeding processed outputs into QGIS, GRASS, or web mapping for enhanced terrain rendering. It's widely used in environmental modeling, hydrology, and remote sensing due to its speed and integration with GDAL's format support for hundreds of raster drivers.
CAVEATS
Input must be elevation raster; NoData handling varies by mode. Color-relief requires valid text file format (elev r g b). Outputs may need projection alignment for overlays.
EXAMPLE: HILLSHADE
gdaldem hillshade -z 1.2 -s 111120 -az 315 input.tif output.tif
EXAMPLE: COLOR-RELIEF
gdaldem color-relief input.tif colors.txt output.png -co PHOTOMETRIC=RGB -alpha
COLOR FILE FORMAT
Lines like: nv 255 0 0
1000 0 255 0
2000 0 0 255 (elev r g b)
HISTORY
Part of GDAL since version 1.10 (2013), developed by Frank Warmerdam and community. Evolved with added modes like TRI/TPI in GDAL 2.x; now in GDAL 3.x for modern geospatial workflows.
SEE ALSO
gdal_translate(1), gdalwarp(1), gdalinfo(1), gdal_contour(1)


