Queries the pixel value at one or more quantiles for a raster object.
Prerequisites
Before calling ST_Quantile, calculate the quantiles of the raster object using ST_StatsQuantile.
Syntax
raster 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
| Parameter | Description |
|---|---|
| raster_obj | The raster object to query. |
| quantiles | The quantiles to calculate pixel values for. Valid values: 0.25, 0.5, and 0.75. Specify one or more values as an array. Default value: NULL, which returns all three quantiles. |
| bands | The band serial numbers to include in the calculation. Supported formats: '0-2' (range) and '1,2,3' (list). Serial numbers start from 0. Default value: empty string (''), which includes all bands. |
| exclude_nodata_value | Specifies whether to exclude NoData values from the calculation. Default value: true. |
| band | Output. The serial number of the band. |
| quantile | Output. The quantile. |
| value | Output. The pixel value at the quantile. |
Examples
Example 1: 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;Output:
band | quantile | value
------+----------+-------
0 | 0.25 | 11
1 | 0.25 | 10
2 | 0.25 | 50
(3 rows)Example 2: Query all quantiles for band 0
Pass NULL for the quantiles parameter to return all three quantiles (0.25, 0.5, and 0.75).
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)该文章对您有帮助吗?