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.
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_geomfromtext ( 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_geomfromtext('POINT Z (1 2 3)'))
0
-- Simple example where we specify the SRID value for the output.
> SELECT SELECT st_asewkt(st_geomfromtext('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_geomfromwkb
functionst_geomfromwkt
functionto_geography
functionto_geometry
functiontry_to_geography
functiontry_to_geometry
function