ST_Histogram — 傳回一組記錄,總結柵格或柵格覆蓋數據分佈的獨立區間範圍。如果未指定,則會自動計算區間數量。
SETOF record ST_Histogram(
raster rast, integer nband=1, boolean exclude_nodata_value=true, integer bins=自動計算, 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)