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 input description of a geometry and returns the corresponding GEOMETRY
value.
The SRID value of the returned GEOMETRY
value depends on the input format.
Syntax
to_geometry ( geoRepExpr )
Arguments
geoRepExpr
: ABINARY
orSTRING
expression representing a geometry in WKB, WKT, GeoJSON, or Extended WKB (EWKB).
Returns
A value of type GEOMETRY(ANY)
, corresponding to the input geography description.
The function returns NULL
if the input is NULL
.
Error conditions
- If
geoRepExpr
is of typeBINARY
and the value is an invalid EWKB, the function returns EWKB_PARSE_ERROR. - If
geoRepExpr
is of typeBINARY
and the value is an invalid WKB, the function returns WKB_PARSE_ERROR. - If
geoRepExpr
is of typeSTRING
and the value is an invalid WKT, the function returns WKT_PARSE_ERROR. - If
geoRepExpr
is of typeSTRING
and the value is an invalid GeoJSON, the function returns GEOJSON_PARSE_ERROR.
Examples
-- Input geometry is in WKT format.
> SELECT st_asgeojson(to_geometry('POINT Z (3 4 5)'))
{"type":"Point","coordinates":[3,4,5]}
-- Input geometry is in GeoJSON format.
> SELECT st_astext(to_geometry('{"type":"Point","coordinates":[3,4,5]}'))
POINT Z (3 4 5)
-- Input geometry is in WKB format.
> SELECT st_astext(to_geometry(X'0101000060110f0000000000000000084000000000000010400000000000001440'))
POINT M (3 4 5)
-- Input geometry is in EWKB format.
> SELECT st_asewkt(to_geometry(X'01010000E0110F0000000000000000084000000000000010400000000000001440000000000000F0BF'))
SRID=3857;POINT ZM (3 4 5 -1)
Related functions
st_asbinary
functionst_asewkb
functionst_asewkt
functionst_asgeojson
functionst_astext
functionst_aswkb
functionst_aswkt
functionst_geogfromgeojson
functionst_geogfromtext
functionst_geogfromwkb
functionst_geogfromwkt
functionst_geomfromewkb
functionst_geomfromgeojson
functionst_geomfromtext
functionst_geomfromwkb
functionst_geomfromwkt
functionto_geography
functiontry_to_geography
functiontry_to_geometry
function