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 Runtime 17.1 and above
Important
This feature is in Public Preview.
Represents a geographic object (point, linestring, polygon, etc.) whose coordinate reference system is geographic and is described by the SRID value of the GEOGRAPHY
type. The underlying space in which the geographic object lives is a periodic space with the first axis representing longitudes in degrees and the second axis representing latitudes in degrees. The coordinates are expected to be in the [-180, 180]
for longitudes and in the [-90, 90]
range for latitudes.
Note
Iceberg tables do not support GEOGRAPHY
columns.
Syntax
GEOGRAPHY ( { srid | ANY } )
Limits
A column of type GEOGRAPHY(ANY)
can hold geographies whose SRID values can be different per row.
A column of type GEOGRAPHY(ANY)
cannot be persisted.
The only SRID value allowed for the GEOGRAPHY
type is 4326
.
The user will get a ST_INVALID_SRID_VALUE error if they try to define a GEOGRAPHY
column with an SRID value other than 4326
.
Literals
For details about how to create a GEOGRAPHY
value, see:
st_geogfromgeojson
functionst_geogfromtext
functionst_geogfromwkb
functionst_geogfromwkt
functionto_geography
functiontry_to_geography
function
Notes
- To convert a
GEOGRAPHY
value to one of the geospatial standard or widely used formats you can use:st_asbinary
function to export aGEOGRAPHY
in WKB format.st_asewkt
function to export aGEOGRAPHY
in Extended WKT (EWKT) format.st_asgeojson
function to export aGEOGRAPHY
in GeoJSON format.st_astext
function to export aGEOGRAPHY
in WKT format.
Examples
> SELECT hex(st_asbinary(st_geogfromtext('POINT(1 2)'));
0101000000000000000000f03f0000000000000040
> SELECT st_asewkt(st_geogfromwkb(X'0101000000000000000000f03f0000000000000040');
SRID=4326;POINT(1 2)
> SELECT st_asgeojson(st_geogfromtext('POINT(1 2)');
{"type":"Point","coordinates":[[1,2]]}
> SELECT st_astext(st_geogfromgeojson('{"type":"Point","coordinates":[[1,2]]}');
POINT(1 2)
> SELECT st_astext(to_geography('{"type":"Point","coordinates":[[1,2]]}');
POINT(1 2)
> SELECT try_to_geography('not a geography value');
NULL