snowflake.snowpark.functions.st_geohash

snowflake.snowpark.functions.st_geohash(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str], precision: Union[snowflake.snowpark.column.Column, str] = None)[source]

Returns the geohash for a GEOGRAPHY or GEOMETRY object.

Parameters:
  • geography_or_geometry_expression (ColumnOrName) – A GEOGRAPHY or GEOMETRY object for which to calculate the geohash

  • precision (ColumnOrName, optional) – The precision of the geohash. If not specified, uses the default precision

Returns:

A string representing the geohash of the input geography or geometry object

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import to_geography
>>> df = session.create_dataframe([["POINT(-122.306100 37.554162)"]], schema=["geom"])
>>> df.select(st_geohash(to_geography(df["geom"])).alias("geohash")).collect()
[Row(GEOHASH='9q9j8ue2v71y5zzy0s4q')]
Copy
>>> df2 = session.create_dataframe([["POINT(-122.306100 37.554162)"]], schema=["geom"])
>>> df2.select(st_geohash(to_geography(df2["geom"]), lit(5)).alias("geohash")).collect()
[Row(GEOHASH='9q9j8')]
Copy