Geocoding

  • Converting a plain text address into a latitude and longitude
  • There are many web based services and APIs
  • I like the geocoder Python library

In [1]:
!sudo pip install geocoder


Downloading/unpacking geocoder
  Downloading geocoder-1.3.1-py2.py3-none-any.whl (52kB): 52kB downloaded
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages (from geocoder)
Requirement already satisfied (use --upgrade to upgrade): click in /usr/local/lib/python2.7/dist-packages (from geocoder)
Downloading/unpacking ratelim (from geocoder)
  Downloading ratelim-0.1.6-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): decorator in /usr/lib/python2.7/dist-packages (from ratelim->geocoder)
Installing collected packages: geocoder, ratelim
Successfully installed geocoder ratelim
Cleaning up...

In [2]:
import geocoder

In [3]:
loc = geocoder.google('200 Corporate Pointe, Culver City, CA')
loc


Out[3]:
<[OK] Google - Geocode [200 Corporate Pointe, Culver City, CA 90230, USA]>

In [4]:
loc.latlng


Out[4]:
{'lat': 33.9876562, 'lng': -118.3833794}

Uses for Geocoding in Data Science

  • Frequent data munging step