Converts a heatmap tile binary into a raster object for visualization and spatial computation.
Syntax
raster ST_HMTAsArray(bytea hmt, text storageOption default '{}');Parameters
| Parameter | Description |
|---|---|
hmt | The heatmap tile binary encoded in protobuf format. Heatmap tiles are produced by ST_AsHMT. |
storageOption | Storage parameters for the raster object, specified as a JSON string. Defaults to '{}', which stores the raster in an anonymous temporary table. For the full list of storage parameters, see ST_CreateRast. |
Usage notes
The spatial reference (SRID) of the input geometry must match the spatial reference used when generating the heatmap with
ST_AsHMT.When
storageOptionis omitted or set to'{}', the raster is stored in an anonymous temporary table.
Description
ST_HMTAsRaster converts heatmap tiles into raster objects. Heatmap tiles are generated by ST_AsHMT, making these two functions complementary steps in the same workflow: ST_AsHMT produces a protobuf-encoded heatmap tile from geometry data, and ST_HMTAsRaster converts that tile back into a raster for rendering or further computation.
Examples
The following example creates a test table with point geometry, weight, and volume columns, generates a heatmap tile with ST_AsHMT, and converts it to a raster with ST_HMTAsRaster. The storageOption parameter is omitted, so the raster is stored in an anonymous temporary table.
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_HMTAsRaster(ST_AsHMT(geom, --geometry type
ST_MakeEnvelope(0, 0, 10, 10, 4326), -- Extent
10, -- Width, in pixel
10 -- height
))
FROM test_table;
---------See also
ST_AsHMT— generates a protobuf-encoded heatmap tile from geometry dataST_CreateRast — reference for
storageOptionparameters