PostGISGeometry Input

ST_Box2dFromGeoHash

What is ST_Box2dFromGeoHash?

ST_Box2dFromGeoHash decodes a GeoHash string into its covering bounding box as a Box2D. Optionally, a precision parameter truncates the GeoHash before decoding.

SQL
ST_Box2dFromGeoHash(text geohash, integer precision = full) → box2d

Longer GeoHash strings give smaller, more precise bounding boxes.

When would you use ST_Box2dFromGeoHash?

Use ST_Box2dFromGeoHash to materialise the rectangular area covered by a GeoHash cell — useful when aggregating feature counts into GeoHash buckets, rendering tile grids, or translating truncated GeoHashes from analytic pipelines back into spatial regions.

It is the inverse of encoding geometries to GeoHash via ST_GeoHash, and pairs naturally with it in round-trip spatial indexing workflows.

FAQs

What is a Box2D?

A PostGIS type representing a 2D axis-aligned bounding box (no SRID stored). Cast to geometry with geometry(box2d_value) or use ST_MakeEnvelope variants.

What precision does a GeoHash give?

Precision depends on length — 1 character ≈ 5000 km, 5 characters ≈ 5 km, 8 characters ≈ 40 m, 12 characters ≈ 3 cm.

Does it return the exact cell?

Yes. GeoHashes represent rectangular cells in lat/lon, and ST_Box2dFromGeoHash returns the exact cell boundary.

What if the GeoHash is invalid?

An error is raised. GeoHash uses a specific base-32 alphabet; malformed strings are rejected.