A geohash is a convenient way of expressing a location (anywhere in the world) using a short alphanumeric string, with greater precision obtained with longer strings.
A geohash actually identifies a rectangular cell: at each level, each extra character identifies one of 32 sub-cells.
The cell sizes of geohashes of different lengths are as follows; note that the cell width reduces moving away from the equator (to 0 at the poles):
|Geohash length||Cell width||Cell height|
Nearby locations generally have similar prefixes, though not always: there are edge-cases straddling
large-cell boundaries; in France, La Roche-Chalais (u000) is just 30km from Pomerol (ezzz).
A reliable prefix search for proximate locations will also search prefixes of a cell’s 8 neighbours.
(e.g. a database query for results within 30-odd kilometres of Pomerol would be
SELECT * FROM MyTable WHERE LEFT(Geohash, 4) IN ('ezzz', 'gbpb, 'u000', 'spbp', 'spbn', 'ezzy', 'ezzw', 'ezzx', 'gbp8').
Whether this would offer significant (or any) performance gains over a latitude/longitude
bounding box search I’ve yet to check.
Database applications might be limited, but geohashes may certainly be easier to communicate than latitude-longitude values: while not exactly memorable, ‘dr5.ru6.j6v’ might be easier to read out to someone than the equivalent ‘40.74879,-73.98547’.
What other applications do people have for geohashes?
Fun geohashes: ‘sunny’ is in Saudi Arabia, ‘fur’ in Greenland, ‘reef’ in the Coral Sea, ‘geek’ in Iceland (sadly, ‘eu’ is in the Maghreb, not Europe, and ‘queen’ [Priscilla?] is lost in the Australian desert).
I offer these scripts for free use and adaptation to balance my debt to the open-source info-verse. You are welcome to re-use these scripts [under an MIT licence, without any warranty express or implied] provided solely that you retain my copyright notice and a link to this page.
If you have any queries or find any problems, contact me at ku.oc.epyt-elbavom@oeg-stpircs.
© 2014–2019 Chris Veness