PostGIS
Name
ST_Contour — Generates a set of vector contours from the provided raster band, using the GDAL contouring algorithm.
Synopsis
setof record +`*`+ST_Contour
*(`raster `rast
, integer
bandnumber
, double precision level_interval
, double precision
level_base
, double precision[] fixed_levels
, boolean
polygonize`
)`;
Description
Generates a set of vector contours from the provided raster band, using the GDAL contouring algorithm.
When the fixed_levels
parameter is a non-empty array, the
level_interval
and level_base
parameters are ignored.
The polygonize
parameter currently has no effect. Use the
ST_Polygonize function to convert contours into
polygons.
Return values are a set of records with the following attributes:
- geom
-
The geometry of the contour line.
- id
-
A unique identifier given to the contour line by GDAL.
- value
-
The raster value the line represents. For an elevation DEM input, this would be the elevation of the output contour.
Availability: 3.2.0
Example
WITH c AS (
SELECT (ST_Contour(rast, 1, fixed_levels => ARRAY[100.0, 200.0, 300.0])).*
FROM dem_grid WHERE rid = 1
)
SELECT st_astext(geom), id, value
FROM c;