Categories:

Geospatial Functions, Conversion Functions

ST_GEOMETRYFROMWKB

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

Aliases:

ST_GEOMFROMWKB , ST_GEOMETRYFROMEWKB , ST_GEOMFROMEWKB

See also:

TO_GEOMETRY

Syntax

ST_GEOMETRYFROMWKB( <varchar_or_binary_expression> )

ST_GEOMFROMWKB( <varchar_or_binary_expression> )

ST_GEOMETRYFROMEWKB( <varchar_or_binary_expression> )

ST_GEOMFROMEWKB( <varchar_or_binary_expression> )

Arguments

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).

Returns

The function returns a value of type GEOMETRY.

Usage Notes

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

  • For WKB input, the resulting GEOMETRY object has SRID set to 0.

    To change the SRID of a GEOMETRY object, pass the GEOMETRY object to ST_SETSRID, specifying the SRID that you want to set. ST_SETSRID returns the GEOMETRY object that has the specified SRID.

Examples

The following example returns the GEOMETRY object for a geospatial object described in EWKB format:

-- Set the geometry output format to EWKT
ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT ST_GEOMETRYFROMEWKB('0101000020797F000066666666A9CB17411F85EBC19E325641');
+---------------------------------------------------------------------------+
| ST_GEOMETRYFROMEWKB('0101000020797F000066666666A9CB17411F85EBC19E325641') |
|---------------------------------------------------------------------------|
| SRID=32633;POINT(389866.35 5819003.03)                                    |
+---------------------------------------------------------------------------+

In the next example, the input is in WKB format, which does not specify the SRID:

-- Set the geometry output format to EWKT
ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT ST_GEOMETRYFROMEWKB('010100000066666666A9CB17411F85EBC19E325641');
+-------------------------------------------------------------------+
| ST_GEOMETRYFROMEWKB('010100000066666666A9CB17411F85EBC19E325641') |
|-------------------------------------------------------------------|
| SRID=0;POINT(389866.35 5819003.03)                                |
+-------------------------------------------------------------------+
Back to top