Skip to content

ST_AsBinary

Converts a geometry or geography to Well-Known Binary (WKB) format.

Usage

binary ST_AsBinary(geom: geometry)
binary ST_AsBinary(geog: geography)

Arguments

  • geog (geography): Input geography
  • geom (geometry): Input geometry

Description

ST_AsBinary() Returns the Well-Known Binary representation of a geometry or geography. This function also has the alias ST_AsWKB.

ST_AsBinary() may preserve the underlying Arrow storage type of the input geometry. For example, when the input geometry is backed by Arrow BinaryView storage, the WKB output may also use BinaryView storage. If a downstream consumer requires simpler Arrow storage such as Binary, wrap the result with sd_simplifystorage().

Examples

SELECT ST_AsBinary(ST_Point(1.0, 2.0));
┌──────────────────────────────────────────────┐
│ st_asbinary(st_point(Float64(1),Float64(2))) │
│                    binary                    │
╞══════════════════════════════════════════════╡
│ 0101000000000000000000f03f0000000000000040   │
└──────────────────────────────────────────────┘
SELECT ST_AsBinary(ST_GeogPoint(1.0, 2.0));
┌──────────────────────────────────────────────────┐
│ st_asbinary(st_geogpoint(Float64(1),Float64(2))) │
│                      binary                      │
╞══════════════════════════════════════════════════╡
│ 0101000000000000000000f03f0000000000000040       │
└──────────────────────────────────────────────────┘