ST_GEOHASH

functionsupportedCore SQL functions

docs.snowflake.com ↗

Geospatial functions

Returns the geohash for a GEOGRAPHY or GEOMETRY object. A geohash is a short base32 string that identifies a great circle rectangle containing a location in the world. The number of characters in a geohash determines precision. Removing characters from the end of a geohash results in a geohash that is less precise and that identifies a larger rectangular area. ST_GEOHASH returns a geohash that is 20 characters long. The optional precision argument specifies the precision of the returned geohash. For example, passing 5 for precision returns a shorter geohash (5 characters long) that is less precise. Note For a geospatial object that is not a point, the function might return a geohash of less precision, regardless of the default or specified value for precision. In these cases, precision is determined by the bounding box of the geospatial object. ST_GEOHASH first determines the geohashes of the lower left and upper right corners of the bounding box and then returns the prefix that is common to these two geohashes.

Syntax

supportedpartialnot supportednot scored

ST_GEOHASH( <geography_expression> [, <precision> ] )

ST_GEOHASH( <geometry_expression> [, <precision> ] )

Parameters

NameRequiredDescription
geography_expressionrequiredThe argument must be an expression of type GEOGRAPHY.
geometry_expressionrequiredThe argument must be an expression of type GEOMETRY with the SRID 4326.
precisionoptionalThe number of characters to use in the geohash. You can specify a value from 1 to 20. By default, precision is 20, which produces a geohash that is 20 characters long.

Returns

Returns the geohash (a value of type STRING) for the specified object. If the object is a Polygon and the two points of the bounding box do not share the same geohash prefix, the function might return an empty string.

See also

Referenced by