重要
此功能目前以公共预览版提供。
以 GeoJSON 格式返回输入 Geography 或 Geometry 值。
有关相应的 Databricks SQL 函数,请参阅 st_asgeojson 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.st_asgeojson(col=<col>)
参数
| 参数 | 类型 | Description |
|---|---|---|
col |
pyspark.sql.Column 或 str |
地理空间值,即 Geography 或 Geometry。 |
例子
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT Z (2.718281 3.141592 100)',)], ['wkt'])
df.select(dbf.st_asgeojson(dbf.st_geogfromtext('wkt')).alias('result')).collect()
[Row(result='{"type":"Point","coordinates":[2.718281,3.141592,100]}')]