All Products
Search
Document Center

PolarDB:ST_HMTStats

Last Updated:Feb 28, 2024

This topic describes the ST_HMTStats function. This function calculates the statistical values of heatmap tiles for being used during rendering.

Syntax

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);

Return values

The statistical values of heatmap tiles are returned. The following parameters are included:

Parameter

Description

min

The minimum value.

max

The maximum value.

mean

The average value.

sum

The sum of values.

count

The total number of statistical values.

std

The standard deviation.

median

The median value.

mode

The mode.

percentile

The array of percentile values. A total of 100 percentile values are included.

Parameters

Parameter

Description

hmt

The heatmap tile binary based on protobuf.

factor

The sampling ratio, indicating the number of values used in each statistical calculation. For example, a factor of 4 indicates that four values are used in each statistical calculation.

Description

This function calculates the statistical values of heatmap tiles for being used during rendering. Heatmap tiles are generated by using the ST_AsHMT function.

Examples

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}