Share via


GEOMETRY type

Applies to: check marked yes Databricks Runtime 17.1 and above

Important

This feature is in Public Preview.

Represents a geometric object (point, linestring, polygon, etc.) whose coordinate reference system is Euclidean for the first (X) and second (Y) coordinates, as well as their Z coordinate if it exists. The underlying coordinate reference system is described by the SRID value of the GEOMETRY type. If the underlying coordinate reference system is unknown the value 0 is used. The units of the X, Y, optionally Z coordinates are those implied by the SRID (except for the SRID value 0 in which case in depends on the user's usage context).

Note

Iceberg tables do not support GEOMETRY columns.

Syntax

GEOMETRY ( { srid | ANY } )

Limits

A column of type GEOMETRY(ANY) can hold geometries whose SRID values can be different per row. A column of type GEOMETRY(ANY) cannot be persisted.

About 11000 SRID values are supported. Learn more about SRID. The user will get a ST_INVALID_SRID_VALUE error if they try to define a GEOMETRY column with an unsupported SRID value.

Literals

For details about how to create a GEOMETRY value, see:

Notes

Examples

> SELECT hex(st_asbinary(st_geomfromtext('POINT(1 2)'));
  0101000000000000000000f03f0000000000000040

> SELECT st_asewkt(st_geomfromwkb(X'0101000000000000000000f03f0000000000000040');
  POINT(1 2)

> SELECT st_asgeojson(st_geomfromtext('POINT(1 2)');
  {"type":"Point","coordinates":[[1,2]]}

> SELECT st_astext(st_geomfromgeojson('{"type":"Point","coordinates":[[1,2]]}');
  POINT(1 2)

> SELECT st_astext(to_geometry('{"type":"Point","coordinates":[[1,2]]}');
  POINT(1 2)

> SELECT try_to_geometry('not a geometry value');
  NULL