All Products
Search
Document Center

PolarDB:ST_PixelAsPoints

Last Updated:Mar 28, 2026

Returns a point geometry for each pixel of a raster, along with the pixel value, row, column, and band. By default, the point coordinates correspond to the upper-left corner of each pixel.

Syntax

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

Parameters

ParameterTypeDefaultDescription
raster_objrasterThe raster to query.
bandinteger0The band to query. Band IDs start from 0.
pyramidinteger0The pyramid level to query.
exclude_nodata_valuebooleantrueSpecifies whether to exclude NoData pixels.
ref_pointcstring'UPPERLEFT'The pixel corner that the returned point geometry represents. Valid values: UPPERLEFT (upper-left corner) and CENTER (center).
rowsnintegerOutput. The row number of the pixel.
columnsnintegerOutput. The column number of the pixel.
bandsnintegerOutput. The band ID of the pixel.
valuedoubleOutput. The pixel value.
geomgeometryOutput. The spatial extent of the pixel.

Description

ST_PixelAsPoints converts each pixel in a raster into a record containing rowsn (row), columnsn (column), bandsn (band ID), value (pixel value), and geom (point geometry). The ref_point parameter controls which corner of the pixel the point geometry represents — UPPERLEFT or CENTER.

Examples

The following example retrieves all pixels from band 1 of the raster with id = 10, then filters for pixels with a value greater than 38.0.

WITH tmp AS (
SELECT (ST_PixelAsPoints(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;POINT(-90 0)

The (ST_PixelAsPoints(...)).* pattern expands the returned setof record into individual columns, which you can then filter and select from in the outer query.