Categories: String, Geospatial, Conversion
ST_GEOHASH
Returns the Geohash string for a given latitude and longitude.
Syntax
ST_GEOHASH(latitude double, longitude double [, precision integer]) → varchar
- latitude: Latitude of the point in degrees.
- longitude: Longitude of the point in degrees.
- precision (optional): Length of the resulting Geohash string (1 to 20). Longer strings encode a more precise location. Default is 20.
Examples
ST_GEOHASH exampleSELECT ST_GEOHASH (42.5049321, -5.7891234, 12)
-- ezecu3b3ptss
SELECT ST_GEOHASH (-82.306100, 37.554162)
-- hc6ey8dh5quv0zpc8w2g
SELECT ST_GEOHASH (-82.306100, 37.554162, 5)
-- hc6ey
SELECT ST_GEOHASH (3.14, -1.34)
-- ebx1ce85zdrtde46u021
SELECT ST_GEOHASH (3.14, -1.34, 5)
-- ebx1c
SELECT ST_GEOHASH(45.4408, 12.3155, 6)
-- u20f80
SELECT ST_GEOHASH(45.4408, 12.3155)
-- u20f80pzggn6km986wf5
SELECT ST_GEOHASH(NULL, 12.3155, 6)
-- null