This function is used to convert the pixels at a specified position of a raster into polygon objects.

Syntax

setof record ST_PixelAsPolygons(raster raster_obj,
    integer band default  0,
    integer pyramid default 0,
    boolean exclude_nodata_value default true,
    out integer rowsn,
    out integer columnsn,
    out integer bandsn,
    out double value,
    out geometry geom);

Parameters

Parameter Description
raster_obj The raster that you want to query.
band The IDs of the bands that you want to query. Valid band IDs start from 0.
pyramid The ID of the pyramid level that you want to query.
exclude_nodata_value Specifies whether to exclude NoData pixels.
rowsn The number of the row in which the pixel resides.
columnsn The number of the column in which the pixel resides.
bandsn The ID of the band to which the pixel belongs.
value The value of the pixel.
geom The spatial extent of the pixel.

Examples

WITH tmp AS (
SELECT (ST_PixelAsPolygons(rast, 1)).*
FROM rast_table
WHERE id = 10 )
SELECT rowsn, columnsn, bandsn, value, ST_AsEWKT(geom)  FROM tmp WHERE value > 38.0;

----------------------------------------------------
    100 |      100 |      0 |    43 | SRID=4326;POLYGON((-180 90,-180 89.1,-179.1 89.1,-179.1 90,-180 90))