2. What's the plan today?
What is geohash?
Why do we need it?
geohash.org
How does it work?
Grouping and Zooming
Nearby (proximity) searches
The Edge case
Limitations
Demo (Let's see it working)
3. Who am I?
Co-Founded Ideophone with @oligoglot & @anenth
helped building @pyka, @suruk, @onetouchsos,
@kopa_app
product architecture, platform development
x-SunTec, x-TAT, mtech from IIIT-B
4. What is geohash?
Simple way to encode lat/long into a string
Compact string encoding of geographic coordinate with
arbitrary precision
Bangalore - TDR1, Domlur - TDR1WX
Invented by Gustavo Niemeyer for geohash.org
Available in public domain http://en.wikipedia.org/wiki/geohash/
5. Why do we need it when we have LL?
Big address of this venue
Complicated Lat/Long {12.963787,77.637789}
The Mail from Cartonama could've said Venue:
"tdr1wxyp5dn7v"
6. ● Subdivides space into "buckets" of grid shape
● Doesn't really represent a point, rather a bounding
area in which the point is present
● Hierarchical spatial structure with gradual degradation
● Longer the geohash
-> Smaller the area
Demo
7. How does it work?
11001 01100 10111 00001 11100 11101 11110 10101 00101 01100 10100 00111 11011
t d r 1 w x y p 5 d n 7 v !
8. geohash.org
Short URL uniquely
identifying points on
earth
Referencing them on
emails, website etc
becomes far more
convenient
Bangalore:
http://geohash.org/tdr1
Domlur:
http://geohash.
org/tdr1wx
10. Nearby (Proximity) Search
● Nearby locations usually share similar prefixes.
● Long common prefixes indicate two places are near,
however two nearby places do not always have
common prefixes
There is an Edge Case:
E.g. Two nearby places in Boston
DRT..
DRM..
13. Finding Nearby Places
● Proximity Search
○ Bottoms-Up
● Bounding Box Search
○ Hops to neighbors
until POI is found
14. Finding Nearby Places
● Compute geohash
values for all Lat/Long
● Have index on
geohash for quicker
retrievals
15. Finding Nearby Places
● Prefix Match:
SELECT * FROM table WHERE place_geohash LIKE hashcode%
● Expand/Neighbors Match
SELECT * FROM table WHERE place_geohash IN (geohash.expand('tzxy1'))
16. Limitations
● Locality Anomalies
○ Complicates Proximity Searches
○ Need to use bounding box extensively making
search an expensive operation
● Projection based model
○ A geohash of given length will denote different
region size in poles than in equator region
18. Conclusions
● Simple and effective system to map complex lat-long
coordinates into simple string representations
● Useful in applications where "nearness" of POIs is
more relevant than accurate distance computation
● Enables quick db access using LIKE using grouping of
prefixes of geohashes