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)
;
为每个区间返回一组记录,包含给定栅格波段的最小值、最大值、计数和百分比。如果未指定波段,则 nband
默认为 1。
默认情况下,仅考虑不等于 |
width
width:一个数组,指示每个类别/区间的宽度。如果箱数大于宽度数,则会重复宽度。
示例:9 个区间,宽度为 [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)