Vectorizes a raster object by grouping pixels with the same value into polygon geometries.
Syntax
setof record ST_Polygonize( raster rast,
integer bandnumber,
cstring options,
out geom geometry,
out id integer,
out value float8);Parameters
| Parameter | Required | Description |
|---|---|---|
rast | Yes | The input raster object. |
bandnumber | Yes | The band number to vectorize. Band numbering starts at 0. |
options | No | The vectorization configuration, specified as a JSON string. See the options fields below. |
options fields
| Field | Type | Description | Default |
|---|---|---|---|
ingoreValue | float | A pixel value to exclude from vectorization, in addition to the nodata value. | 0 |
Return value
ST_Polygonize returns a set of records, one per distinct pixel value group. Each record contains the following fields:
| Field | Type | Description |
|---|---|---|
geom | geometry | The polygon geometry representing the region covered by pixels of the same value. |
id | integer | The sequential identifier of the record. |
value | float8 | The pixel value shared by all pixels in the polygon. |
Examples
The following example vectorizes band 1 of the raster stored in rast_table where id = 1, excluding pixels with value 0.
select ST_Polygonize(rast, 1, '{"ingoreValue":0}') from rast_table where id = 1;Input

Output
