views:

394

answers:

1

I'm trying to do some network analysis for a client. The provided road-network GIS layer is of bad quality; therefore, I have to resort to Google maps to provide me shortest path between 200 points, to produce time and distance matrices between each point.

is there a way i can input the layer as a set of KML points to obtain outputs of the distance and time between these points ?

if this is doable via the api, do you have any hints or suggestions on how to write such a script?

EDIT the ideal final result would be a CSV file of the following form:

node_1, node_2, distance, travel_time
node_n, node_m, distance, travel_time
+2  A: 

I won't write the whole script for you, but this can be done with the maps API. Open up the maps sandbox and add to the onGDirectionsLoad function:

alert(gdir.getDistance().meters);

You can find the documentation here - a getDuration() is also available. Then all you need to do is issue a new request once one finished, getting directions for each pair of start and end point.

However, note that if you're planning on getting 200*200 paths, google may decide to rate limit you at some point. Use this method at your own risk, and with a delay between requests.

Note also that google's builtin KML support doesn't seem to support giving you the list of points - this makes sense, since the client may only have those that are currently onscreen. You might need to write your own KML loader if you want to use KML as the input format. Or use a simpler format, as in this example.

bdonlan
Are you aware of any other ways I can produce a distance matrix?
dassouki