All Products
Search
Document Center

ApsaraDB RDS:ST_Quantile

Last Updated:Mar 28, 2026

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

Prerequisites

Run ST_StatsQuantile to calculate the quantiles for the raster object before calling ST_Quantile.

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

Input parameters

ParameterTypeDefaultDescription
raster_objrasterThe raster object to query.
quantilesfloat8[]NULLThe quantiles to return. Valid values: 0.25, 0.5, and 0.75. Pass NULL to return all three quantiles.
bandscstring''The serial numbers of the bands to include. Supported formats: '0-2' (range) and '1,2,3' (list). Serial numbers start from 0. An empty string (default) includes all bands.
exclude_nodata_valuebooleantrueSpecifies whether to exclude NoData values from the query.

Output parameters

ParameterTypeDescription
bandintegerThe serial number of the band.
quantilefloat8The quantile value.
valuefloat8The pixel value at the quantile.

Examples

Example 1: Return the pixel value at the 0.25 quantile for all bands (bands 0–2).

SELECT (ST_Quantile(rast, ARRAY[0.25], '0-2', true)).* FROM rat_quantile WHERE id = 1;

Output:

 band | quantile | value
------+----------+-------
    0 |     0.25 |    11
    1 |     0.25 |    10
    2 |     0.25 |    50
(3 rows)

Example 2: Return pixel values at all quantiles (0.25, 0.5, 0.75) for band 0.

SELECT (ST_Quantile(rast, NULL, '0', true)).* FROM rat_quantile WHERE id = 1;

Output:

 band | quantile | value
------+----------+-------
    0 |     0.25 |    11
    0 |      0.5 |    11
    0 |     0.75 |    65
(3 rows)