This topic describes the ST_Value function. This function returns the pixel value of a band.

Syntax

float8 ST_Value(raster raster_obj, 
        integer band,
        integer column_sn,
        integer row_sn,
        boolean exclude_nodata default true);
float8 ST_Value(raster raster_obj, 
        integer band,
        float8  x,
        float8  y,
        boolean exclude_nodata default true);

Parameters

Parameter Description
raster_obj The raster object that you want to clip.
band The number of the band from which you want to obtain the pixel value. The band number starts from 0.
column_sn The number of the column in which the pixel is located. The number of the column is calculated from the upper-left corner of the raster object.
row_sn The number of the row in which the pixel is located. The number of the row is calculated from the upper-left corner of the raster object.
x The x coordinate of the pixel.
y The y coordinate of the pixel.
exclude_nodata Specifies whether to return a NoData value.

If the value is true and the pixel value is NoData, NULL is returned.

Description

This function returns the pixel value of a band based on the x and y coordinates as well as the row number or column number of the pixel.

Examples

SELECT ST_VALUE(rast_obj, 0, 10, 20)
FROM raster_table
WHERE id = 1;

---------
169

SELECT ST_Value(rast_obj, 0, 150::float8, 20::float8, false)
from raster_table
WHERE id=3;

----------
77