共用方式為


st_geohash

這很重要

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

回傳輸入 幾何體的地幾雜希值。

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

語法

from pyspark.databricks.sql import functions as dbf

dbf.st_geohash(col1=<col1>, col2=<col2>)

參數

參數 類型 Description
col1 pyspark.sql.Columnstr 幾何的值。
col2 pyspark.sql.Columnint,選用 輸出 geohash 的可選精度(有效位數)。 必須是非負數。

範例

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT(-122.4261475 37.77374268)',)], ['wkt'])
df.select(dbf.st_geohash(dbf.st_geomfromtext('wkt')).alias('result')).collect()
[Row(result='9q8yyhebpbpb')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT(-122.4261475 37.77374268)',)], ['wkt'])
df.select(dbf.st_geohash(dbf.st_geomfromtext('wkt'), 6).alias('result')).collect()
[Row(result='9q8yyh')]