适用于:
Databricks SQL
Databricks Runtime 17.1 及更高版本
Important
此功能目前以公共预览版提供。
注释
此功能在 Databricks SQL 经典仓库上不可用。 若要详细了解 Databricks SQL 仓库,请参阅 SQL 仓库类型。
解析几何体的输入描述,并返回相应的GEOMETRY值;如果输入描述无效,则返回NULL。
返回 GEOMETRY 值的 SRID 值取决于输入格式。
Syntax
try_to_geometry ( geoRepExpr )
Arguments
-
geoRepExpr:表示BINARY、STRING或扩展 WKB(EWKB)中的几何图形的表达式。
Returns
一个与输入几何图形说明相对应的类型GEOMETRY(ANY)值。
- 如果输入为
NULL.,则函数返回NULL。 - 如果输入
NULL或BINARY值是几何图形的无效说明,该函数将STRING返回。
Examples
-- Input geometry is in WKT format.
> SELECT st_asgeojson(try_to_geometry('POINT Z (3 4 5)'));
{"type":"Point","coordinates":[3,4,5]}
-- Input geometry is in GeoJSON format.
> SELECT st_astext(try_to_geometry('{"type":"Point","coordinates":[3,4,5]}'));
POINT Z (3 4 5)
-- Input geometry is in WKB format.
> SELECT st_astext(try_to_geometry(X'0101000060110f0000000000000000084000000000000010400000000000001440'));
POINT M (3 4 5)
-- Input geometry is in EWKB format.
> SELECT st_asewkt(try_to_geometry(X'01010000E0110F0000000000000000084000000000000010400000000000001440000000000000F0BF'));
SRID=3857;POINT ZM (3 4 5 -1)
-- Input value is not the description of a geometry.
> SELECT st_astext(try_to_geometry('some string that does not represent a geometry'))
NULL
相关函数
-
st_asbinary函数 -
st_asewkb函数 -
st_asewkt函数 -
st_asgeojson函数 -
st_astext函数 -
st_aswkb函数 -
st_aswkt函数 -
st_geogfromgeojson函数 -
st_geogfromtext函数 -
st_geogfromwkb函数 -
st_geogfromwkt函数 -
st_geomfromewkb函数 -
st_geomfromgeojson函数 -
st_geomfromtext函数 -
st_geomfromwkb函数 -
st_geomfromwkt函数 -
to_geography函数 -
to_geometry函数 -
try_to_geography函数