Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026.
We will start enforcing it in phases. For more information on the details of Python end of life
and migration options, see the
blog post
ST_GeoHash
ST_GeoHash returns the geohash representation of the input point with the specified precision.
The default precision value is 20.
For more information about the definition of geohash, see Geohash
Syntax
ST_GeoHash(geom)
ST_GeoHash(geom, precision)
Arguments
- geom
-
A value of data type
GEOMETRYor an expression that evaluates to aGEOMETRYtype. - precision
-
A value of data type
INTEGER. The default is 20.
Return type
GEOMETRY
The function returns the geohash representation of the input point.
If the input point is empty, the function returns null.
If the input geometry is not a point, the function returns an error.
Examples
The following SQL returns the geohash representation of the input point.
SELECT ST_GeoHash(ST_GeomFromText('POINT(45 -45)'), 25) AS geohash;
geohash
---------------------------
m000000000000000000000gzz
The following SQL returns null because the input point is empty.
SELECT ST_GeoHash(ST_GeomFromText('POINT EMPTY'), 10) IS NULL AS result;
result
---------
true