Categories:

Geospatial functions, Conversion functions

ST_GEOGRAPHYFROMWKT

Parses a WKT (well-known text) (link removed) or EWKT (extended well-known text) input and returns a value of type GEOGRAPHY.

Aliases:

ST_GEOGFROMWKT , ST_GEOGRAPHYFROMEWKT , ST_GEOGFROMEWKT , ST_GEOGRAPHYFROMTEXT , ST_GEOGFROMTEXT

See also:

TO_GEOGRAPHY

Syntax

ST_GEOGRAPHYFROMWKT( <varchar_expression> [ , <allow_invalid> ] )

ST_GEOGFROMWKT( <varchar_expression> [ , <allow_invalid> ] )

ST_GEOGRAPHYFROMEWKT( <varchar_expression> [ , <allow_invalid> ] )

ST_GEOGFROMEWKT( <varchar_expression> [ , <allow_invalid> ] )

ST_GEOGRAPHYFROMTEXT( <varchar_expression> [ , <allow_invalid> ] )

ST_GEOGFROMTEXT( <varchar_expression> [ , <allow_invalid> ] )
Copy

Arguments

Required:

varchar_expression

The argument must be a string expression in WKT or EWKT that represents a valid geospatial object.

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 WKT or EWKT.

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

  • For the coordinates in WKT, EWKT, and GeoJSON, longitude appears before latitude (e.g. POINT(lon lat)).

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_GEOGRAPHYFROMWKT('POINT(-122.35 37.55)');
Copy
+---------------------------------------------+
| ST_GEOGRAPHYFROMWKT('POINT(-122.35 37.55)') |
|---------------------------------------------|
| POINT(-122.35 37.55)                        |
+---------------------------------------------+

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

-- Set the output format to WKT
alter session set GEOGRAPHY_OUTPUT_FORMAT='WKT';
Copy
select ST_GEOGRAPHYFROMWKT('POINTZ(-122.35 37.55 30)');
Copy
+-------------------------------------------------+
| ST_GEOGRAPHYFROMWKT('POINTZ(-122.35 37.55 30)') |
|-------------------------------------------------|
| POINTZ(-122.35 37.55 30)                        |
+-------------------------------------------------+

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_GEOGRAPHYFROMEWKT('SRID=4326;POINT(-122.35 37.55)');
Copy
+--------------------------------------------------------+
| ST_GEOGRAPHYFROMEWKT('SRID=4326;POINT(-122.35 37.55)') |
|--------------------------------------------------------|
| SRID=4326;POINT(-122.35 37.55)                         |
+--------------------------------------------------------+
Language: English