Returns the polygon geometry that bounds a specified pixel in a raster.
Syntax
geometry ST_PixelAsPolygon(raster raster_obj,
integer row default 0,
integer column default 0,
integer pyramid default 0);Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
raster_obj | raster | — | The raster to query. |
row | integer | 0 | The row index of the pixel. Indexes start at 0, which refers to the top-left pixel of the raster. |
column | integer | 0 | The column index of the pixel. Indexes start at 0, which refers to the top-left pixel of the raster. |
pyramid | integer | 0 | The pyramid level of the pixel. |
Examples
Retrieve the polygon boundary for the pixel at row 10, column 10:
SELECT ST_AsText(ST_PixelAsPolygon(rast, 10, 10))
FROM rast_table
WHERE id = 10;Result:
POLYGON((3427927.75 5793244,3427927.8 5793244,3427927.8 5793243.95,...See also
ST_PixelAsPolygons: Returns polygon geometries for all pixels in a raster, or for a specified band.
ST_PixelAsPoint: Returns the point geometry of a specified pixel's upper-left corner.
ST_AsText: Converts a geometry to Well-Known Text (WKT) format.