GeoHash
encode(lat/long) --> 'string'
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)
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
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/
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"
● 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
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 !
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
Grouping and Zooming
Easy grouping
   ○ tdr1wxyp5dn7v -> {12.9637069, 77.6377931}
         ●   4th Main Rd, Domlur II Stage, Domlur, Bengaluru, Karnataka

   ○ tdr1wxyp5dn7v -> {12.9637, 77.6378}
         ●   Domlur, Bengaluru, Karnataka

   ○ tdr1wxyp5dn7v -> {12.96, 77.64}
         ●   Bengaluru, Karnataka

   ○ tdr1wxyp5dn7v -> {13, 78}
         ●   Malur-Bangarapettu Rd
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..
Nearby Search
tdr1wxyp5dn7v (TERI)
tdr1wxyqekmg (Bangalore I'ntl Chapter)
tdr1y8jbvrmc (Domlur Club)
tdr1y8jykh6w (CIS)
tdr1ybmhdj4p (Ideophone)
tdr1v4e3mecx (Majestic Station)
tf346wn2t49t (Chennai Central)
9q8vzpgn7we0 (SFO Airport)
Finding Nearby Places
Python, Perl, PHP, Java etc
python-geohash
    ○   Encode/Decode
    ○   BoundingBox
           {'s': 12.919921875,

           'e': 77.6513671875,

           'w': 77.607421875,

           'n': 12.9638671875}

    ○   Neighbours
           ['ezefx','ezefr','ezefp','ezs40',

           'ezs41','ezs43','ezs49','ezs48']
Finding Nearby Places
● Proximity Search
   ○ Bottoms-Up




                        ● Bounding Box Search
                           ○ Hops to neighbors
                             until POI is found
Finding Nearby Places

● Compute geohash
  values for all Lat/Long
● Have index on
  geohash for quicker
  retrievals
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'))
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
Demo
http://openlocation.org/geohash/geohash-js/
http://geohash.gofreerange.com/
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
Thank you!
@sandeepbhaskar
https://github.com/sandeepbhaskar/geohash-demo

Geohash

  • 1.
  • 2.
    What's the plantoday? 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-FoundedIdeophone 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? Simpleway 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 weneed 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 spaceinto "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 itwork? 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
  • 9.
    Grouping and Zooming Easygrouping ○ tdr1wxyp5dn7v -> {12.9637069, 77.6377931} ● 4th Main Rd, Domlur II Stage, Domlur, Bengaluru, Karnataka ○ tdr1wxyp5dn7v -> {12.9637, 77.6378} ● Domlur, Bengaluru, Karnataka ○ tdr1wxyp5dn7v -> {12.96, 77.64} ● Bengaluru, Karnataka ○ tdr1wxyp5dn7v -> {13, 78} ● Malur-Bangarapettu Rd
  • 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..
  • 11.
    Nearby Search tdr1wxyp5dn7v (TERI) tdr1wxyqekmg(Bangalore I'ntl Chapter) tdr1y8jbvrmc (Domlur Club) tdr1y8jykh6w (CIS) tdr1ybmhdj4p (Ideophone) tdr1v4e3mecx (Majestic Station) tf346wn2t49t (Chennai Central) 9q8vzpgn7we0 (SFO Airport)
  • 12.
    Finding Nearby Places Python,Perl, PHP, Java etc python-geohash ○ Encode/Decode ○ BoundingBox {'s': 12.919921875, 'e': 77.6513671875, 'w': 77.607421875, 'n': 12.9638671875} ○ Neighbours ['ezefx','ezefr','ezefp','ezs40', 'ezs41','ezs43','ezs49','ezs48']
  • 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
  • 17.
  • 18.
    Conclusions ● Simple andeffective 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
  • 19.