Skip to main content

st_geohash

Preview

This feature is in Public Preview.

Returns the geohash of the input Geometry.

For the corresponding Databricks SQL function, see st_geohash function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

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

Parameters

Parameter

Type

Description

col1

pyspark.sql.Column or str

A Geometry value.

col2

pyspark.sql.Column or int, optional

The optional precision (number of significant digits) of the output geohash. Must be non-negative.

Examples

Python
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()
Output
[Row(result='9q8yyhebpbpb')]
Python
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()
Output
[Row(result='9q8yyh')]