All Products
Search
Document Center

PolarDB:ST_Polygonize

Last Updated:Mar 28, 2026

Vectorizes a raster band by pixel value, returning one (geom, id, value) row per contiguous region of identical pixel values.

Syntax

setof record ST_Polygonize(
    raster  rast,
    integer bandnumber,
    cstring options,
    out geom  geometry,
    out id    integer,
    out value float8
);

Parameters

ParameterTypeRequiredDescription
rastrasterYesThe input grid object.
bandnumberintegerYesThe band to vectorize. Band numbering starts at 0.
optionscstringNoA JSON string with vectorization options. If omitted, defaults apply.

Output columns

ColumnTypeDescription
geomgeometryThe polygon geometry for a contiguous pixel region.
idintegerA sequential identifier for each output row.
valuefloat8The pixel value shared by all pixels in the region.

options fields

FieldTypeDefaultDescription
ingoreValuefloat0A pixel value to exclude from vectorization. Pixels with this value are not converted to polygons.
ingoreValue and NoData are separate exclusion mechanisms. NoData pixels are always excluded from vectorization regardless of the ingoreValue setting. Use ingoreValue to additionally exclude a specific valid pixel value (for example, background pixels with value 0).

Example

The following query vectorizes band 1 of the raster 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 raster

image.png

Output polygons

image.png

Each output row contains a polygon geometry (geom), a row identifier (id), and the pixel value (value) for that region.