This function is used to convert the pixels at a specified position of a raster into geometric objects, each of which is represented by a specified point of the geometric object.

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

Parameter Description
raster_obj The raster that you want to query.
band The IDs of the bands that you want to query. Valid band IDs start from 0.
pyramid The ID of the pyramid level that you want to query.
exclude_nodata_value Specifies whether to exclude NoData pixels.
ref_point The reference position of the point in the geometric object. Valid values:
  • UPPERLEFT: specifies the point that resides in the upper-left corner of the geometric object.
  • CENTER: specifies the point that resides in the center of the geometric object.
rowsn The number of the row in which the pixel resides.
columnsn The number of the column in which the pixel resides.
bandsn The ID of the band to which the pixel belongs.
value The value of the pixel.
geom The spatial extent of the pixel.

Description

This function converts the pixels at a specified position of a raster into geometric objects, each of which is represented by a specified point of the geometric object. The reference position of the point is specified by the ref_point parameter.

Examples

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)