ST_Histogram — 返回一组记录,总结了栅格或栅格覆盖数据分布,其中包括分离的分箱范围。如果未指定,将自动计算分箱数。
SETOF record ST_Histogram(
raster rast, integer nband=1, boolean exclude_nodata_value=true, integer bins=autocomputed, double precision[] width=NULL, boolean right=false)
;
SETOF record ST_Histogram(
raster rast, integer nband, integer bins, double precision[] width=NULL, boolean right=false)
;
SETOF record ST_Histogram(
raster rast, integer nband, boolean exclude_nodata_value, integer bins, boolean right)
;
SETOF record ST_Histogram(
raster rast, integer nband, integer bins, boolean right)
;
返回每个 bin 给定栅格波段的记录集,其中包含最小值、最大值、计数、百分比。 如果未指定 band,则 nband
默认为 1。
默认情况下,仅考虑不等于 |
width
width:一个数组,指示每个category/bin 的宽度。 如果箱的数量大于宽度的数量,则宽度会重复。
示例:9 个 bin,宽度为 [a, b, c] 将输出为 [a, b, c, a, b, c, a, b, c]
bins
分组数量——这是您将从函数中返回的记录数(如果指定)。 如果未指定,则自动计算分组数量。
right
从右侧而不是从左侧计算直方图(默认)。 这将评估值 x 的标准从 [a, b) 更改为 (a, b]
更改:3.1.0 删除了 ST_Histogram(table_name, column_name) 变体。
可用性: 2.0.0
SELECT band, (stats).* FROM (SELECT rid, band, ST_Histogram(rast, band) As stats FROM dummy_rast CROSS JOIN generate_series(1,3) As band WHERE rid=2) As foo; band | min | max | count | percent ------+-------+-------+-------+--------- 1 | 249 | 250 | 2 | 0.08 1 | 250 | 251 | 2 | 0.08 1 | 251 | 252 | 1 | 0.04 1 | 252 | 253 | 2 | 0.08 1 | 253 | 254 | 18 | 0.72 2 | 78 | 113.2 | 11 | 0.44 2 | 113.2 | 148.4 | 4 | 0.16 2 | 148.4 | 183.6 | 4 | 0.16 2 | 183.6 | 218.8 | 1 | 0.04 2 | 218.8 | 254 | 5 | 0.2 3 | 62 | 100.4 | 11 | 0.44 3 | 100.4 | 138.8 | 5 | 0.2 3 | 138.8 | 177.2 | 4 | 0.16 3 | 177.2 | 215.6 | 1 | 0.04 3 | 215.6 | 254 | 4 | 0.16
SELECT (stats).* FROM (SELECT rid, ST_Histogram(rast, 2,6) As stats FROM dummy_rast WHERE rid=2) As foo; min | max | count | percent ------------+------------+-------+--------- 78 | 107.333333 | 9 | 0.36 107.333333 | 136.666667 | 6 | 0.24 136.666667 | 166 | 0 | 0 166 | 195.333333 | 4 | 0.16 195.333333 | 224.666667 | 1 | 0.04 224.666667 | 254 | 5 | 0.2 (6 rows) -- Same as previous but we explicitly control the pixel value range of each bin. SELECT (stats).* FROM (SELECT rid, ST_Histogram(rast, 2,6,ARRAY[0.5,1,4,100,5]) As stats FROM dummy_rast WHERE rid=2) As foo; min | max | count | percent -------+-------+-------+---------- 78 | 78.5 | 1 | 0.08 78.5 | 79.5 | 1 | 0.04 79.5 | 83.5 | 0 | 0 83.5 | 183.5 | 17 | 0.0068 183.5 | 188.5 | 0 | 0 188.5 | 254 | 6 | 0.003664 (6 rows)