适用于: Databricks SQL
Databricks Runtime 17.1 及更高版本
重要
此功能目前以公共预览版提供。
分析地理位置的输入说明并返回相应的 GEOGRAPHY
值。
返回 GEOGRAPHY
值的 SRID 值为 4326。
Syntax
to_geography ( geoRepExpr )
Arguments
-
geoRepExpr
:一种BINARY
或STRING
表达式,表示 WKB、WKT 或 GeoJSON 中的地理信息。
退货
一个类型 GEOGRAPHY(ANY)
值,对应于输入地理说明。
如果输入为 NULL
.,则函数返回 NULL
。
错误条件
- 如果
geoRepExpr
类型为类型BINARY
且值为无效的 WKB,则函数将返回 WKB_PARSE_ERROR。 - 如果
geoRepExpr
类型为类型STRING
且值无效的 WKT,则函数将返回 WKT_PARSE_ERROR。 - 如果
geoRepExpr
类型为,STRING
并且值无效 GeoJSON,则函数将返回 GEOJSON_PARSE_ERROR。
例子
-- Input geography is in WKT format.
> SELECT st_asgeojson(to_geography('POINT Z (3 4 5)'));
{"type":"Point","coordinates":[3,4,5]}
-- Input geography is in GeoJSON format.
> SELECT st_asewkt(to_geography('{"type":"Point","coordinates":[3,4,5]}'));
SRID=4326;POINT Z (3 4 5)
-- Input geography is in WKB format.
> SELECT st_astext(to_geography(X'01b90b0000000000000000084000000000000010400000000000001440000000000000f0bf'))
POINT ZM (3 4 5 -1)
相关函数
-
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_geometry
函数 -
try_to_geography
函数 -
try_to_geometry
函数