Converts a pixel in a raster to a geometry point, with the point positioned at a specified reference location within the pixel.
Syntax
geometry ST_PixelAsPoint(raster raster_obj,
integer row default 0,
integer column default 0,
integer pyramid default 0,
cstring ref_point default 'UPPERLEFT');Parameters
| Parameter | Description |
|---|---|
raster_obj | The raster to query. |
row | The row number of the pixel. Row numbers start from 0, which corresponds to the top row of the raster. Default value: 0. |
column | The column number of the pixel. Column numbers start from 0, which corresponds to the leftmost column of the raster. Default value: 0. |
pyramid | The pyramid level of the pixel. Default value: 0. |
ref_point | The reference position within the pixel used to generate the output point. Default value: UPPERLEFT. Valid values:
|
Description
ST_PixelAsPoint returns a geometry point representing a single pixel in a raster. The output point coordinates correspond to the position specified by ref_point—either the upper-left corner or the center of the pixel.
Row and column numbers are zero-indexed. The pixel at row 0, column 0 is in the upper-left corner of the raster.
Examples
Get the upper-left corner point of the pixel at row 10, column 10:
SELECT ST_AsText(ST_PixelAsPoint(rast, 10, 10))
FROM rast_table
WHERE id = 10;Output:
POINT(-178.2 88.2)