st_geomfromwkt
function
Applies to: Databricks SQL
Databricks Runtime 17.1 and above
This feature is in Public Preview.
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types
Parses the WKT description of a geometry and returns the corresponding GEOMETRY
value.
The SRID value of the returned GEOMETRY
value is the value of the sridExpr
if specified, or 0 otherwise.
Syntax
st_geomfromwkt ( wktExpr[, sridExpr] )
Arguments
wktExpr
: ASTRING
value, representing a geometry in WKT format.sridExpr
: An optionalINTEGER
value that is set to be the SRID of the returnedGEOMETRY
value.
Returns
A value of type GEOMETRY(srid)
where srid
is the value of sridExpr
if sridExpr
is a constant (foldable) expression, or GEOMETRY(ANY)
otherwise.
If sridExpr
is omitted the type of the returned value is GEOMETRY(0)
.
The returned value is the geometry corresponding to the input WKT description.
The function returns NULL
if any of the inputs is NULL
.
Error conditions
- If the value of
wktExpr
is an invalid WKT description, the function returns WKT_PARSE_ERROR. - If the value of
sridExpr
is unsupported, the function returnsST_INVALID_SRID_VALUE
.
Examples
-- Simple example where we do not specify the output SRID. It defaults to 0.
> SELECT st_srid(st_geomfromwkt('POINT Z (1 2 3)'));
0
-- Simple example where we specify the SRID value for the output.
> SELECT st_asewkt(st_geomfromwkt('POINT Z (1 2 3)', 3857));
SRID=3857;POINT Z (1 2 3)
Related functions
st_asbinary
functionst_asewkb
functionst_asewkt
functionst_asgeojson
functionst_astext
functionst_geogfromgeojson
functionst_geogfromtext
functionst_geogfromwkb
functionst_geogfromwkt
functionst_geomfromewkb
functionst_geomfromgeojson
functionst_geomfromtext
functionst_geomfromwkb
functionto_geography
functionto_geometry
functiontry_to_geography
functiontry_to_geometry
function