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 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:
st_geomfromgeojson
functionst_geomfromtext
functionst_geomfromwkb
functionst_geomfromwkt
functionto_geometry
functiontry_to_geometry
function
Notes
- To convert a
GEOMETRY
value to one of the geospatial standard or widely used formats you can use:st_asbinary
function to export aGEOMETRY
in WKB format.st_asewkb
function to export aGEOMETRY
in Extended WKB (EWKB) format.st_asewkt
function to export aGEOMETRY
in Extended WKT (EWKT) format.st_asgeojson
function to export aGEOMETRY
in GeoJSON format.st_astext
function to export aGEOMETRY
in WKT format.
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