All Products
Search
Document Center

ApsaraDB RDS:ST_AsBinary

Last Updated:Mar 28, 2026

Converts a grid object into its Well-Known Binary (WKB) representation.

Syntax

bytea ST_AsBinary(geomgrid grid)
bytea ST_AsBinary(h3grid grid)

Parameters

ParameterDescription
gridThe grid object to convert. Accepts GeomGrid or H3Grid data types.

Examples

GeomGrid (2D)

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
--------------------
 \x0102000f74271236

GeomGrid (3D)

SELECT st_asbinary(unnest(st_as3dgrid(
  'srid=4490;POINT(116.31522216796875 39.910277777777778 1001.8)'::geometry, 20)));

Output:

          st_asbinary
--------------------------------
 \x0102401474271236362412000000

H3Grid

SELECT st_asbinary(st_h3fromlatlng(20.5, 128.2, 8));

Output:

       st_asbinary
--------------------------
 \x010100ffff9f6826a18408