重要
此功能目前以公共预览版提供。
分析输入 BINARY 或字符串值并返回相应的 Geography 值。 检测到无效输入时会抛出错误。
有关相应的 Databricks SQL 函数,请参阅 to_geography 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.to_geography(col=<col>)
参数
| 参数 | 类型 | Description |
|---|---|---|
col |
pyspark.sql.Column 或 str |
WKT 或 GeoJSON 格式的字符串值,或表示 Geography 值的 WKB 格式的 BINARY 值。 |
例子
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT Z (3 4 5)',)], ['wkt'])
df.select(dbf.st_asewkt(dbf.to_geography('wkt')).alias('result')).collect()
[Row(result='SRID=4326;POINT Z (3 4 5)')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('{"type":"MultiPoint","coordinates":[[3,4,5]]}',)], ['geojson'])
df.select(dbf.st_asewkt(dbf.to_geography('geojson')).alias('result')).collect()
[Row(result='SRID=4326;MULTIPOINT Z ((3 4 5))')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(bytes.fromhex('01ef0300000100000001e9030000000000000000084000000000000010400000000000001440'),)], ['wkb'])
df.select(dbf.st_asewkt(dbf.to_geography('wkb')).alias('result')).collect()
[Row(result='SRID=4326;GEOMETRYCOLLECTION Z (POINT Z (3 4 5))')]