Share via


GEOGRAPHY type

Applies to: check marked yes 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:

Notes

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