Generates contour lines based on the DEM elevation values in a region.
Syntax
set of record ST_Contour(
raster rast,
integer band,
cstring contourOptions);Parameters
Parameter | Description |
rast | The raster object. Currently, only a DEM with one band is supported. |
band | The band number, starting from 0. |
contourOptions | The parameters for generating contour lines. |
contourOptions supports the following parameters:
Parameter | Description | Type | Default value | Remarks |
level_base | The starting contour value. | float | 0.0 | N/A. |
fixed_level | Specifies the values of each contour line as a float array. | float array | None | If fixed_level is specified, interval is ignored. |
interval | The interval between contour lines. | float | None | N/A. |
polygonize | The output contour type. | bool | false | The type of contour to create:
|
nodata | The nodata value. | float | -1.0 | N/A. |
Description
Generates contour lines by specifying a raster object and a band number.
The fields in the returned result include:
id: The sequence number of the contour line or polygon.
max_value: The maximum value in the contour line or polygon.
min_value: The minimum value in the contour line or polygon.
geom: The geometry object of the contour line or polygon.
Examples
-- Specify interval. Return lines
select (ST_Contour(rast,0,'{"interval":"2.0"}')).* from raster_table where id =1;
-- Specify the contour intervals as an array. Return polygons
select (ST_Contour(rast,0,'{"fixed_level":[1,5,10,15,20,30],"polygonize":"true"}')).* from raster_table where id =1;
-- Specify nodata. Return polygons
select (ST_Contour(rast,0,'{"interval":"5","nodata":"0.0","level_base":"1.0","polygonize":"true"}')).* from raster_table where id =1;