ST_GeoHash - Amazon Redshift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

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 in Wikipedia.

Syntax

ST_GeoHash(geom)
ST_GeoHash(geom, precision)

Arguments

geom

A value of data type GEOMETRY or an expression that evaluates to a GEOMETRY type.

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