ST_ Geohash
The ST_Geohash function returns the geohash of the specified point geometry at the specified depth.The ST_Geohash function returns the unique geohash value of the specified point geometry at depth=45.
Syntax
Parameter
- point_geometry
- A value of type ST_Point that represents the point geometry for which the geohash is to be calculated. If the specified geometry is NULL or empty, one row with a geohash value of NULL is returned.
- depth
- A value of type INTEGER in the range 1 - 45 that determines the size of the geohash cell. The
following table lists some of the most commonly used depths their corresponding approximate cell
sizes.
Geohash Depth Approximate Cell Size Description Examples 45 0.1 km2 Single point or address GPS-location or house 28 3 km2 Small region city block 23 100 km2 Medium-sized region forest or lake 18 3,000 km2 Large region county or postal code area 13 100,000 km2 Very large (huge) region state or country Geohash values of two geometries that are to be compared must be computed using the same depth. An attempt to compare geohash values computed using different depths is invalid.
Restrictions
The specified point geometry must use SRS 4326 (GSE3001N).
- The number of rows returned by this function cannot exceed 10,000 (SQL0443N).
- The specified point geometry must use SRS 4326 (GSE3001N).
Output
A single BIGINT value that is the geohash value of the specified point geometry at depth=45.
A column of type BIGINT with the name GEOHASH containing the geohash value of the specified point geometry at the specified depth.
Example
The following SQL statement returns the geohash, at depth 45, of the point geometry with the coordinates (1,2):
values st_geohash(st_point(1,2))
1
--------------------
-4610318878716198912
1 record(s) selected.
Example
select geohash from table(st_geohash(st_point(1,2), 40))
GEOHASH
--------------------
-4611686018427387904