Returns the centroid (point geometry) of the area represented by a pixel.
Syntax
geometry ST_PixelAsCentroid(raster raster_obj,
integer row default 0,
integer column default 0,
integer pyramid default 0);Parameters
| Parameter | Description |
|---|---|
raster_obj | The raster to query. |
row | The row index of the pixel. Valid values start from 0, where 0 is the upper-left corner. |
column | The column index of the pixel. Valid values start from 0, where 0 is the upper-left corner. |
pyramid | The pyramid level of the pixel. |
Description
ST_PixelAsCentroid converts a specified raster pixel into a point geometry at the center of that pixel's area. This is equivalent to calling ST_PixelAsPoint with ref_point set to CENTER.
Example
SELECT ST_AsText(ST_PixelAsCentroid(rast, 10, 10))
FROM rast_table
WHERE id = 10;Output:
POINT(-178.2 88.2)See also
ST_PixelAsPoint — Returns a point geometry at a specified reference position within a pixel, such as the upper-left corner or center.