ST_Quantile
更新时间:
复制 MD 格式
Returns the pixel values at specified quantiles for a raster object.
Prerequisites
Before calling ST_Quantile, calculate the quantiles of the raster object using ST_StatsQuantile.
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
| Parameter | Description |
|---|---|
raster_obj | The name of the raster object. |
quantiles | The quantiles to calculate. Valid values: 0.25, 0.5, and 0.75. Specify one or more values as an array. |
bands | The bands to include in the calculation. Supported formats: '0-2' (range) and '1,2,3' (list). Band serial numbers start from 0. Default value: '' (empty string), which includes all bands. |
exclude_nodata_value | Specifies whether to include NoData values during calculation. Default value: true. |
band | Output. The band serial number. |
quantile | Output. The quantile value. |
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 quantile pixel values for band 0
Passing NULL for the quantiles parameter returns pixel values for 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)See also
ST_StatsQuantile: Calculate quantiles for a raster object before querying with
ST_Quantile.
该文章对您有帮助吗?