Categories: String, Geospatial, Conversion
ST_GEOHASH
Returns the corresponding geohash for the given latitude and longitude coordinates.
Syntax
ST_GEOHASH(latitude double, longitude double [, precision integer]) → varchar
- latitude: Latitude of the location to encode.
- longitude: Longitude of the location to encode.
- precision (optional): The number of characters to use in the geohash (minimum is 1, maximum is 20, 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