This topic describes the ST_Contour function. This function generates contours based on the digital elevation model (DEM) data in the area.
Syntax
set of record ST_Contour(
raster rast,
integer band,
cstring contourOptions);
Parameters
Parameter | Description |
rast | The raster object, which must be a digital elevation model (DEM) that has only one band. |
band | The band number, which starts from 0. |
contourOptions | The fields that are used to generate contours. |
The following table describe the fields of the contourOptions parameter.
Field | Description | Type | Default | Remarks |
level_base | The start of the contour value. | float | 0.0 | None |
fixed_level | Specifies the interval between contours. The value is an array of floating-point numbers. | float array | None | If you specify the fixed_level field, you can ignore the interval field. |
interval | The contour spacing. | float | None | None |
polygonize | The type of the output contour. | bool | false | The type of the contour to create.
|
nodata | The nodata value. | float | -1.0 | None |
Description
This function generates contours based on the specified raster object and band number.
The return value includes the following fields:
id: the sequence number of the contour line or plane.
max_value: the maximum value in the contour line or plane.
min_value: the minimum value in the contour line or plane.
geom: the geometry object of the contour line or plane.
Examples
-- If the interval field is specified, a contour line is returned.
select (ST_Contour(rast,0,'{"interval":"2.0"}')).* from raster_table where id =1;
-- If the interval field is set to an array, a polygon is returned.
select (ST_Contour(rast,0,'{"fixed_level":[1,5,10,15,20,30],"polygonize":"true"}')).* from raster_table where id =1;
-- If the nodata field is specified, a polygon is returned.
select (ST_Contour(rast,0,'{"interval":"5","nodata":"0.0","level_base":"1.0","polygonize":"true"}')).* from raster_table where id =1;