ST_GeoHash — Return a GeoHash representation (geohash.org) of the geometry.
text ST_GeoHash(geometry geom, integer maxchars=full_precision_of_point
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.
maxchars is specficified ST_GeoHash returns a GeoHash based on full precision of 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.
maxchars is specified ST_GeoHash returns a GeoHash with at most that many characters so a possibly lower precision representation of the input geometry. 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