All Products
Search
Document Center

ApsaraDB RDS:ST_Percentile

Last Updated:Mar 28, 2026

Returns the pixel value at a given percentile for a specified band of a raster — for example, the value below which 25%, 50%, or 75% of pixels fall. Use this function to analyze pixel intensity or elevation distributions in raster data.

Syntax

float8 ST_Percentile(raster raster_obj, integer band, integer percentage)

Parameters

ParameterTypeDescription
raster_objrasterThe raster to query.
bandintegerThe band ID. Valid IDs start from 0.
percentageintegerThe target percentile. The raster must have precomputed percentile statistics before you call this function. To precompute statistics, call ST_BuildPercentiles or ST_ComputeStatistics.

Examples

The following examples query the 10th, 25th, and 50th percentiles for band 0 of a raster row.

Query a single percentile

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

Result:

29.7

Query multiple percentiles

ST_Percentile produces the same result as ST_Quantile. The following example retrieves the 25th and 50th percentiles in a single query.

SELECT st_percentile(rast_obj, 0, 25), st_percentile(rast_obj, 0, 50)
FROM raster_table
WHERE id = 1;

See also