Constructs a geometry object from a Geohash string.
Syntax
geometry ST_GeomFromGeoHash(text geohash, integer precision);Parameters
| Parameter | Description |
|---|---|
geohash | The Geohash string. |
precision | The precision level used to construct the geometry object. If omitted, the function returns a polygon at full precision. |
Examples
Construct a geometry object at full precision
SELECT ST_AsText(ST_GeomFromGeoHash('wx47x9u8gumnhzp791zb'));Output:
st_astext
---------------------------------------------------------------
POLYGON((116 39.9999999999999,116 40,116 40,116 39.9999999999999,116 39.9999999999999))
(1 row)Construct a geometry object at a custom precision
SELECT ST_AsText(ST_GeomFromGeoHash('wx47x9u8gumnhzp791zb', 2));Output:
st_astext
---------------------------------------------------------------
POLYGON((112.5 39.375,112.5 45,123.75 45,123.75 39.375,112.5 39.375))
(1 row)该文章对您有帮助吗?