This topic describes how to obtain the percentage of bands for imagery.

Syntax

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

Parameters

Parameter Description
raster_obj The raster object.
band The IDs of the bands. Example: '0,1-3,6,8'. Valid band IDs start from 0. If you set this parameter to '', all bands of the raster are specified.
percentage The percentage of the specified bands for the raster object. You can use ST_BuildPercentiles or ST_ComputeStatistics to obtain the percentage.

Examples

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

--------------------
29.7
You can also use ST_Percentile to implement the ST_Quantile feature.
SELECT st_percentile(rast_obj, 0, 25), st_percentile(rast_obj, 0, 50)
FROM raster_table
WHERE id = 1;