tags:

views:

239

answers:

3

I have a large number of GIS (latitude, longitude) coordinates, and I'd like to get the distance between them. Is there a service that will calculate the shortest path for me? I know about google maps, but I'd like something I can use from Python, and that can handle a large batch of requests at once.

I'm looking for the driving distance, so a straight distance won't do.

Thanks

A: 

If you have interconnections between the points you could use Dijkstra's algorithm for a 'shortest path from a single point' or Floyd's algorithm for an 'all pairs' shortest path computation.

Neither are particularly complicated, however they do assume you know the lengths of the roads between the points. You will need to have this data to compute a driving distance.

ConcernedOfTunbridgeWells
No, but I'm running this on real street data, and I don't have a graph of that lying around. I'm looking for a service like google maps, except one that I can communicate with from python, and send a lot of data to.Something like this would be great:https://webgis.usc.edu/Services/ShortestPath/Default.aspxBut it looks like it isn't open to the public yet.
Paul
+1  A: 

Check out OpenStreetMap. You can download their map data and have it lying around on your local system. http://wiki.openstreetmap.org/wiki/Routing discusses the various routing systems for their data.

You are aware that the traveling salesman problem is np-complete?

joeforker
Yep. This is for an applied algorithms class, where we're learning about techniques for approximating NP-hard problems. =)
Paul
+1  A: 

using Qgis:

  • Use the delimited text plugin to import the data
  • save the import as a shape file
  • Open the shape file
  • using the ftools plugin, calculate the matrix distance
dassouki