geo-registry

Contour

Lines joining cells of equal value in a raster, at a regular interval.

Pitfall. Contours are interpolated between cell centres, so they are only as precise as the cell size; engines differ on whether lines stop at the outermost cell centres (GRASS) or run to the raster's edge (GDAL).
Pitfall. Some engines smooth or simplify the lines by default, which changes their lengths and positions slightly.
About this operation
Also called contours, contour lines, isolines, Contour List
Group raster/surface
Checks raster.nodata, geometry.valid
Pitfalls 2 listed above
Columbus tool Not stated
Notes Not stated
Status active
Broader Not stated
Narrower Not stated
Related

Parameters

Name Type Required Default Values Note
interval number yes Not stated Not stated Spacing between levels, in the raster's value units.
base number no 0 Not stated Levels are base plus multiples of interval.
field string no Not stated Not stated Name of the attribute that holds each line's level.
band integer no 1 Not stated Not stated

Inputs and outputs

Direction Name Type Geometry Note
Input raster raster Not stated Not stated
Output output vector line Not stated

In each engine

Engine Tool Parameters Differences
gdal gdal raster contour
  • interval → interval
  • base → offset
  • field → elevation-name
  • band → band
  • raster → input
  • output → output
None noted
grass r.contour
  • interval → step
  • base No offset; minlevel and maxlevel limit the levels, or levels lists them.
  • field The level goes in the attribute table's level column.
  • raster → input
  • output → output
None noted
postgis-raster st_contour
  • interval → level_interval
  • base → level_base
  • field Returns rows of (geom, id, value); value is the level.
  • band → bandnumber
  • raster → rast
None noted
qgis gdal:contour
  • interval → INTERVAL
  • base → OFFSET
  • field → FIELD_NAME
  • band → BAND
  • raster → INPUT
  • output → OUTPUT
None noted
terra terra::as.contour
  • interval Give levels (or nlevels), passed through ... to grDevices::contourLines.
  • raster → x
  • Uses at most maxcells cells (default 100,000), sampling larger rasters.
whiteboxtools ContoursFromRaster
  • interval → interval
  • base → base
  • raster → input
  • output → output
  • Smooths (smooth, default 9) and simplifies (tolerance, default 10) the lines by default.
xarray-spatial xrspatial.contours
  • interval Give levels: a list of values (default n_levels evenly spaced levels).
  • raster → agg
  • Returns (level, coordinates) pairs, or a GeoDataFrame with return_type = 'geopandas'.