This topic describes the ST_GeomFromGeoHash function. This function constructs a geometry object by using a Geohash string.
Syntax
geometry ST_GeomFromGeoHash(text geohash , integer precision);
Parameters
Parameter | Description |
---|---|
geohash | The Geohash string that you want to specify. |
precision | The precision based on which you want to construct the geometry object. If you do not specify a precision, this function returns a polygon by using the Geohash string in the full precision. |
Examples
- Construct a geometry object by using the full precision.
SELECT ST_AsText(ST_GeomFromGeoHash('wx47x9u8gumnhzp791zb')); st_astext --------------------------------------------------------------- POLYGON((116 39.9999999999999,116 40,116 40,116 39.9999999999. .999,116 39.9999999999999)) (1 row)
- Construct a geometry object by using a custom precision.
SELECT ST_AsText(ST_GeomFromGeoHash('wx47x9u8gumnhzp791zb',2)); st_astext --------------------------------------------------------------- POLYGON((112.5 39.375,112.5 45,123.75 45,123.75 39.375,112.5 . .39.375)) (1 row)