Converts a grid object into a binary structure.
Syntax
bytea ST_AsBinary(geomgrid grid)
bytea ST_AsBinary(h3grid grid)Parameters
| Parameter | Description |
|---|---|
grid | The grid object to convert. Accepts GeomGrid and H3Grid data types. |
Examples
Convert a 2D GeomGrid to binary
WITH g AS (
SELECT unnest(ST_AsGrid(
ST_GeomFromText('POINT(116.31522216796875 39.910277777777778)', 4490), 15)) AS grid
)
SELECT ST_AsBinary(grid) FROM g;Output:
st_asbinary
--------------------
\x0102000f74271236Convert a 3D GeomGrid to binary
SELECT ST_AsBinary(unnest(ST_As3DGrid(
'srid=4490;POINT(116.31522216796875 39.910277777777778 1001.8)'::geometry, 20)));Output:
st_asbinary
--------------------------------
\x0102401474271236362412000000Convert an H3Grid to binary
SELECT ST_AsBinary(ST_H3FromLatLng(20.5, 128.2, 8));Output:
st_asbinary
--------------------------
\x010100ffff9f6826a18408