views:

614

answers:

8

Hi,

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.

Best,

Bruno

+2  A: 

You could take a look at GeoLite City. It's free (GPL), but they say it's not the most accurate.

Over 99.5% on a country level and 79% on a city level for the US within a 25 mile radius

That still might suit you, depending on your needs.

nickf
+5  A: 

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).

dF
+2  A: 

Both Google and Microsoft have API's that are very easy to hook into. There are some limitations but they are pretty generous. You might also want to look at http://geocoder.us/. I am not aware of any free geocoding services that are any good (and I have spent time looking!)

Craig
+4  A: 

Geopy lets you choose from several geocoders (including Google, Yahoo, Virtual Earth).

Aaron
A: 

You can use a web API like google maps to find the coordinates. Then if you just need to calculate distances (in a straight line), there is a formula you can apply to get pretty accurate results.

Vasil
A: 

The USC WebGIS Geocoder (https://webgis.usc.edu) is free. It has API's that you can call from scripts or you can upload and process databases (mdb, csv, etc.). The accuracy levels depend on where your addresses are. For example, in Los Angeles County parcel centroids are available, while in other parts of the country only TIGER/Lines are. A coverage map of reference data sources is not available at this time, but is in development. The underlying tools are planned to be open-sourced in the future once more development is completed as well.

A: 

I came across http://www.geonames.org/ the other day. You can actually download all the data for postcodes, including lat / long etc even for commericial use to save having to connect to external sources. I think you can do the same for city names (post code data has subrub names associated with it already).

Some maths on finding the distance "As The Crow Flies" - direct from point to point can be found here and here (.NET example).

RM
A: 

You can have better look in Geopy module.And it is worth enough to use as it contains Google map, yahoo map geocoders with which you can implement geocodings.

rahman.bd