I'm using python and I need to map locations like "Bloomington, IN" to GPS coordinates so I can measure distances between them. What Geocoding libraries/APIs do you recommend? Solutions in other languages are also welcome.
Geopy lets you choose from several geocoders (including Google, Yahoo, Virtual Earth).
The Google's web service is very easy to use. Just put the query in the URL. To make it even easier/lazier, I will shamelessly advertise pygeocoder, a Python wrapper for Google Geocoding. Then you can just do something like
print Geocoder.geocode("Montreal, Canada")[0].coordinates
to get a tuple with coordinates. You can also do stuff like
Geocoder.geocode("sushi, San Francisco").count
or
Geocoder.geocode("sushi, San Francisco")[0].postal_code
The Google Maps API supports geocoding, and the Python Cookbook has a simple example of accessing it from Python (although the recipe doesn't use the API directly, just simple maps.google.com URLs).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With