Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks SQL
Databricks Runtime 17.1 and above
Important
This feature is in Public Preview.
Note
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Parses the input description of a geography and returns the corresponding GEOGRAPHY value.
The SRID value of the returned GEOGRAPHY value is 4326.
Syntax
to_geography ( geoRepExpr )
Arguments
Returns
A value of type GEOGRAPHY(ANY), corresponding to the input geography description.
The function returns NULL if the input is NULL.
Error conditions
- If
geoRepExpris of typeBINARYand the value is an invalid WKB, the function returns WKB_PARSE_ERROR. - If
geoRepExpris of typeSTRINGand the value is an invalid WKT, the function returns WKT_PARSE_ERROR. - If
geoRepExpris of typeSTRINGand the value is an invalid GeoJSON, the function returns GEOJSON_PARSE_ERROR.
Examples
-- Input geography is in WKT format.
> SELECT st_asgeojson(to_geography('POINT Z (3 4 5)'));
{"type":"Point","coordinates":[3,4,5]}
-- Input geography is in GeoJSON format.
> SELECT st_asewkt(to_geography('{"type":"Point","coordinates":[3,4,5]}'));
SRID=4326;POINT Z (3 4 5)
-- Input geography is in WKB format.
> SELECT st_astext(to_geography(X'01b90b0000000000000000084000000000000010400000000000001440000000000000f0bf'))
POINT ZM (3 4 5 -1)
Related functions
st_asbinaryfunctionst_asewkbfunctionst_asewktfunctionst_asgeojsonfunctionst_astextfunctionst_aswkbfunctionst_aswktfunctionst_geogfromgeojsonfunctionst_geogfromtextfunctionst_geogfromwkbfunctionst_geogfromwktfunctionst_geomfromewkbfunctionst_geomfromgeojsonfunctionst_geomfromtextfunctionst_geomfromwkbfunctionst_geomfromwktfunctionto_geometryfunctiontry_to_geographyfunctiontry_to_geometryfunction