ST_GeoHash — Return a GeoHash representation (geohash.org) of the geometry.
text ST_GeoHash(geometry g1
text ST_GeoHash(geometry g1, integer precision
Return a GeoHash representation (geohash.org) of the geometry. A GeoHash encodes a point into a text form that is sortable and searchable based on prefixing. A shorter GeoHash is a less precise representation of a point. It can also be thought of as a box, that contains the actual point.
The one-parameter variant of ST_GeoHash returns a GeoHash based on the input geometry type. Points return a GeoHash with 20 characters of precision (about enough to hold the full double precision of the input). Other types return a GeoHash with a variable amount of precision, based on the size of the feature. Larger features are represented with less precision, smaller features with more precision. The idea is that the box implied by the GeoHash will always contain the input feature.
The two-parameter variant of ST_GeoHash returns a GeoHash with a requested precision. For non-points, the starting point of the calculation is the center of the bounding box of the geometry.
ST_GeoHash will not work with geometries that are not in geographic (lon/lat) coordinates.
This method supports Circular Strings and Curves
SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326)); st_geohash ---------------------- c0w3hf1s70w3hf1s70w3 SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326),5); st_geohash ------------ c0w3h