Automatically find all latitude and longitude of all my locations
Question: I have a long list of vendors I would like to find the latitude and longitude
for. I already have the addresses.

Is this something I can do using Python? or can I do it with another language?

I just started learning Python.


Answer: The process you are describing is called
"[geocoding](https://developers.google.com/maps/documentation/geocoding/start)".

Python can't do the conversion of addresses to coordinates itself, since it
needs a large database of addresses. However online services such as google or
microsoft-bing can geocode addresses, and you can use python to access these
services.

For example you can use the standard "requests" module to look up an address

    
    
    >>> import requests
    >>> url = 'https://maps.googleapis.com/maps/api/geocode/json'
    >>> params = {'sensor': 'false', 'address': 'Mountain View, CA'}
    >>> r = requests.get(url, params=params)
    >>> results = r.json()['results']
    >>> location = results[0]['geometry']['location']
    >>> location['lat'], location['lng']
    (37.3860517, -122.0838511)
    

The process can be simplified with the [geocoding
package](https://pypi.python.org/pypi/geocoder) (which you would have to
install yourself):

    
    
    >>> import geocoder
    >>> g = geocoder.google('Mountain View, CA')
    >>> g.latlng
    (37.3860517, -122.0838511)
    

(These examples are taken from the geocoding documentation)

Google and other geocoding providers do place limits on your access to their
services. For google I believe it is [2500 per day and 50 per
second](https://developers.google.com/maps/documentation/geocoding/usage-
limits).

In conclusion: python can't do geocoding itself, but it does help you access
services that can.

