Name

ST_GeomFromGeoHash — Return a geometry from a GeoHash string.

Synopsis

geometry ST_GeomFromGeoHash(text geohash, integer precision=full_precision_of_geohash);

Description

Return a geometry from a GeoHash string. The geometry will be a polygon representing the GeoHash bounds.

If no precision is specified ST_GeomFromGeoHash returns a polygon based on full precision of the input GeoHash string.

If precision is specified ST_GeomFromGeoHash will use that many characters from the GeoHash to create the polygon.

Availability: 2.1.0

Examples

The cells are returned together so their relative sizes remain visible in a shared coordinate frame.

Code
SELECT ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 4) AS "precision 4", ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 5) AS "precision 5", ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 6) AS "precision 6";
Output
-[ RECORD 1 ]----------
precision 4 | POLYGON((-115.3125 36.03515625,-115.3125 36.2109375,-114.9609375 36.2109375,-114.9609375 36.03515625,-115.3125 36.03515625))
precision 5 | POLYGON((-115.1806640625 36.0791015625,-115.1806640625 36.123046875,-115.13671875 36.123046875,-115.13671875 36.0791015625,-115.1806640625 36.0791015625))
precision 6 | POLYGON((-115.1806640625 36.112060546875,-115.1806640625 36.1175537109375,-115.169677734375 36.1175537109375,-115.169677734375 36.112060546875,-115.1806640625 36.112060546875))
Figure
Geometry figure for visual-st-geomfromgeohash-01