計算熱力圖瓦片統計值資訊,方便在渲染時使用。
文法
record ST_HMTAsArray(bytea hmt, integer factor default 1, out float8 min, out float8 max, out float8 mean, out float8 sum , out float8 count , out float8 std, out float8 median, out float8 mode, out float8[] percentile);
傳回值
返回熱力圖瓦片統計值資訊記錄,欄位說明如下:
欄位名稱 | 描述 |
min | 最小值。 |
max | 最大值。 |
mean | 平均值。 |
sum | 資料之和。 |
count | 資料個數。 |
std | 標準差。 |
median | 中位元。 |
mode | 眾數。 |
percentile | 百分比數組。總共100個數值,表示每個百分比對應的數值。 |
參數
參數名稱 | 描述 |
hmt | 基於protobuf表示的HMT二進位。 |
factor | 採樣比例,即每多少個資料進行統計計算。例如,factor為4,表示每4個值進行統計。 |
描述
計算熱力圖瓦片統計值資訊,方便在渲染時使用。 熱力圖瓦片需要通過ST_AsHMT函數產生。
樣本
CREATE TABLE test_table AS
SELECT i num,
ST_setSRID(st_makepoint((i-0.5)::numeric, (i-0.5)::numeric), 4326) geom,
i*100::int4 weight,
i*i*i::float8 volume
FROM generate_series(1, 10) i;
SELECT (ST_HMTstats(ST_AsHMT(the_geom,
ST_MakeEnvelope(0, 0, 10, 10),
10,
10))).*
FROM test_table;
------------------
min | max | mean | sum | count | std | median | mode | percentile
0 | 2 | 0.19 | 19 | 100 | 0.5778408085277467 | 0 | 0 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,2,2}
-- factor set to 4
SELECT (ST_HMTstats(ST_AsHMT(the_geom,
ST_MakeEnvelope(0, 0, 10, 10),
10,
10),4)).*
FROM test_table;
------------------
min | max | mean | sum | count | std | median | mode | percentile
0 | 2 | 0.16 | 4 | 25 | 0.5425863986500215 | 0 | 0 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2}