This function is used to convert a specified pixel of a raster into a polygon object.

Syntax

geometry ST_PixelAsPolygon(raster raster_obj,   
                            integer row default 0,   
                            integer column default 0   
                            integer pyramid default 0) ;

Parameters

Parameter Description
raster_obj The raster that you want to query.
row The number of the row in which the pixel resides. Valid row numbers start from 0, which indicates the pixel in the upper-left corner of the raster.
column The number of the column in which the pixel resides. Valid column numbers start from 0, which indicates the pixel in the upper-left corner of the raster.
pyramid The pyramid level in which the pixel resides.

Examples

SELECT ST_AsText(ST_PixelAsPolygon(rast, 10, 10))
FROM rast_table
WHERE id = 10;

------------------
POLYGON((3427927.75 5793244,3427927.8 5793244,3427927.8 5793243.95,...