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.
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_geomfromgeojsonfunctionst_geomfromtextfunctionst_geomfromwkbfunctionst_geomfromwktfunctionto_geometryfunctiontry_to_geometryfunction
Notes
- To convert a
GEOMETRYvalue to one of the geospatial standard or widely used formats you can use:st_asbinaryfunction to export aGEOMETRYin WKB format.st_asewkbfunction to export aGEOMETRYin Extended WKB (EWKB) format.st_asewktfunction to export aGEOMETRYin Extended WKT (EWKT) format.st_asgeojsonfunction to export aGEOMETRYin GeoJSON format.st_astextfunction to export aGEOMETRYin 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