All Products
Search
Document Center

ApsaraDB RDS:ST_PixelAsCentroids

Last Updated:Mar 28, 2026

Converts pixels at a specified position of a raster into geometry objects, each represented by the centroid of the pixel.

Syntax

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

Parameters

ParameterTypeDefaultDescription
raster_objrasterThe raster to query.
bandinteger0The band ID to query. Valid band IDs start from 0.
pyramidinteger0The pyramid level to query.
exclude_nodata_valuebooleantrueSpecifies whether to exclude NoData pixels.
rowsnout integerThe row number of the pixel.
columnsnout integerThe column number of the pixel.
bandsnout integerThe band ID of the pixel.
valueout doubleThe pixel value.
geomout geometryThe spatial extent of the pixel.

Description

ST_PixelAsCentroids returns the same results as ST_PixelAsPoints when the ref_point parameter of ST_PixelAsPoints is set to CENTER.

Examples

WITH tmp AS (
SELECT (ST_PixelAsCentroids(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(-89.5 0.5)