Categories:

Geospatial functions, Conversion functions

ST_GEOGRAPHYFROMWKB¶

Parses a WKB (well-known binary) or EWKB (extended well-known binary) input and returns a value of type GEOGRAPHY.

Aliases:

ST_GEOGFROMWKB , ST_GEOGRAPHYFROMEWKB , ST_GEOGFROMEWKB

See also:

TO_GEOGRAPHY

Syntax¶

ST_GEOGRAPHYFROMWKB( <varchar_or_binary_expression> [ , <allow_invalid> ] )

ST_GEOGFROMWKB( <varchar_or_binary_expression> [ , <allow_invalid> ] )

ST_GEOGRAPHYFROMEWKB( <varchar_or_binary_expression> [ , <allow_invalid> ] )

ST_GEOGFROMEWKB( <varchar_or_binary_expression> [ , <allow_invalid> ] )
Copy

Arguments¶

Required:

varchar_or_binary_expression

The argument must be a string or binary expression in WKB or EWKB that represents a valid geospatial object.

A string expression must be in hexadecimal format (without a leading 0x).

Optional:

allow_invalid

If TRUE, specifies that the function should return a GEOGRAPHY or GEOMETRY object, even when the input shape is invalid and cannot be repaired. For details, refer to Specifying how invalid geospatial shapes are handled.

Returns¶

The function returns a value of type GEOGRAPHY.

Usage notes¶

  • Issues an error if the input cannot be parsed as WKB or EWKB.

  • Issues an error if the input format is EWKB and the SRID is not 4326. See the note on EWKT and EWKB handling.

Examples¶

The following example returns the GEOGRAPHY object for a geospatial object described in WKT format:

-- Set the output format to WKT
alter session set GEOGRAPHY_OUTPUT_FORMAT='WKT';
Copy
select ST_GEOGRAPHYFROMWKB('01010000006666666666965EC06666666666C64240');
+-------------------------------------------------------------------+
| ST_GEOGRAPHYFROMWKB('01010000006666666666965EC06666666666C64240') |
|-------------------------------------------------------------------|
| POINT(-122.35 37.55)                                              |
+-------------------------------------------------------------------+
Copy

The following example returns the GEOGRAPHY object for a geospatial object described in EWKT format:

-- Set the output format to EWKT
alter session set GEOGRAPHY_OUTPUT_FORMAT='EWKT';
Copy
select ST_GEOGRAPHYFROMEWKB('0101000020E61000006666666666965EC06666666666C64240');
+----------------------------------------------------------------------------+
| ST_GEOGRAPHYFROMEWKB('0101000020E61000006666666666965EC06666666666C64240') |
|----------------------------------------------------------------------------|
| SRID=4326;POINT(-122.35 37.55)                                             |
+----------------------------------------------------------------------------+
Copy