共用方式為


st_geogfromgeojson

這很重要

這項功能目前處於 公開預覽版

解析 GeoJSON 描述並回傳對應 的地理 值。

關於對應的 Databricks SQL 函式,請參見 st_geogfromgeojson 函數

語法

from pyspark.databricks.sql import functions as dbf

dbf.st_geogfromgeojson(col=<col>)

參數

參數 類型 Description
col pyspark.sql.Columnstr 一個以 GeoJSON 格式組成的字串值,代表 地理 值。

範例

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('{"type":"Polygon","coordinates":[[[0,0],[5,6],[7,-8],[0,0]]]}',)], ['geojson'])
df.select(dbf.st_asewkt(dbf.st_geogfromgeojson('geojson')).alias('result')).collect()
[Row(result='SRID=4326;POLYGON((0 0,5 6,7 -8,0 0))')]