ST_Histogram — 返回一组记录,用于汇总栅格或栅格覆盖数据分布的各个 bin 范围。如果未指定,则自动计算 bin 的数量。
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 的给定栅格波段的最小值、最大值、计数和百分比。如果未指定波段,nband
默认为 1。
默认情况下,只考虑不等于 |
width
double precision[]宽度:一个数组,表示每个类别/bin 的宽度。如果 bin 的数量大于宽度的数量,则重复宽度。
示例:9 个 bin,宽度为 [a, b, c],输出为 [a, b, c, a, b, c, a, b, c]
bins
integer分段数——这是如果指定,您将从函数中获取的记录数。如果未指定,则自动计算分段数。
right
boolean从右侧而不是从左侧(默认)计算直方图。这会更改评估值 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)