Categories:

Geospatial Functions

ST_ASWKB , ST_ASBINARY

Given a value of type GEOGRAPHY, return the binary representation of that value in WKB (well-known binary) format.

See also:

ST_ASEWKB

Syntax

Use one of the following:

ST_ASWKB( <geography_expression> )

ST_ASBINARY( <geography_expression> )

Arguments

geography_expression

The argument must be an expression of type GEOGRAPHY.

Returns

A value of type BINARY.

Usage Notes

  • ST_ASBINARY is an alias for ST_ASWKB.

  • To return the output in EWKB format, use ST_ASEWKB instead.

Examples

The following example demonstrates the ST_ASWKB function. For the WKB output, it is assumed that the BINARY_OUTPUT_FORMAT parameter is set to HEX (the default value for the parameter).

create table geospatial_table (g GEOGRAPHY);
insert into geospatial_table values
    ('POINT(-122.35 37.55)'), ('LINESTRING(-124.20 42.00, -120.01 41.99)');
select st_aswkb(g)
    from geospatial_table;
+------------------------------------------------------------------------------------+
| ST_ASWKB(G)                                                                        |
|------------------------------------------------------------------------------------|
| 01010000006666666666965EC06666666666C64240                                         |
| 010200000002000000CDCCCCCCCC0C5FC00000000000004540713D0AD7A3005EC01F85EB51B8FE4440 |
+------------------------------------------------------------------------------------+