All Products
Search
Document Center

PolarDB:ST_Quantile

Last Updated:Mar 28, 2026

Queries the pixel values at specified quantiles for a raster object.

Run ST_StatsQuantile on the raster object before calling ST_Quantile. ST_Quantile reads pre-computed statistics rather than recalculating them.

Syntax

setof record ST_Quantile(raster raster_obj,
                   float8[] quantiles default NULL,
                   cstring bands default '',
                   boolean exclude_nodata_value default true,
                   out integer band,
                   out float8 quantile,
                   out float8 value)

Parameters

ParameterTypeDefaultDescription
raster_objrasterThe raster object to query.
quantilesfloat8[]NULLThe quantiles to compute. Valid values: 0.25, 0.5, and 0.75. Specify one or more values as an array. If NULL, all three quantiles (0.25, 0.5, 0.75) are returned.
bandscstring''The bands to include. Use '0-2' for a range or '1,2,3' for individual bands. Band serial numbers start from 0. An empty string selects all bands.
exclude_nodata_valuebooleantrueSpecifies whether to exclude NoData pixels from the calculation.
band (out)integerThe band serial number.
quantile (out)float8The quantile value.
value (out)float8The pixel value at that quantile.

Examples

All examples use the rat_quantile table and expand the setof record result with .*.

Query the 0.25 quantile pixel value across all bands.

SELECT (ST_Quantile(rast, ARRAY[0.25], '0-2', true)).* FROM rat_quantile WHERE id = 1;
 band | quantile | value
------+----------+-------
    0 |     0.25 |    11
    1 |     0.25 |    10
    2 |     0.25 |    50
(3 rows)

Query pixel values at the 0.25, 0.5, and 0.75 quantiles for band 0.

Passing NULL for the quantiles parameter returns all three common quantiles.

SELECT (ST_Quantile(rast, NULL, '0', true)).* FROM rat_quantile WHERE id = 1;
 band | quantile | value
------+----------+-------
    0 |     0.25 |    11
    0 |      0.5 |    11
    0 |     0.75 |    65
(3 rows)