Here's my situation:

  • I'm modeling travel logistics
  • I have 1,000 nodes, on my road network
  • I'd like to generate the minimum driving time distance between all these nodes
  • This process will be done 24 times (24 hours / day)

Is this possible?

1 Answer 1


The way I read this there are a couple of possibilities: You have cost data for each hour in a 24 hour period; or you have 1,000 nodes which change position every hour across your network. I'm assuming either way that you have the directionality and costs of the network sorted.

In either case you should be able to do this through GRASS. Import the network as a vector layer with your costs.

I'll deal with the second case first:

  1. Attach the 24 hourly costs of your road as fields to the network. It's up to you whether you want the time cost columns in one table, or whether you want them in 24, to join up one at a time as you run the process. If you want different costings based on direction, then you need to add these columns also.
  2. Join your 1000 nodes to your network with v.net.
  3. Run v.net.allpairs to find the distances between all nodes for a time cost column(s).
  4. Rinse and repeat: scripting might be your best bet if you have to do this a bunch of times. Otherwise it might be easier to just run the process manually.

The first case is slightly more tricky, and you'd probably want to script it once you've gotten the process down:

  1. Join your 1000 nodes to your network with v.net.
  2. Run v.net.allpairs to find the distances between all nodes for a time cost column(s).
  3. Start again with the next set of 1000 nodes. As I say, this would be better to script if you can as it is very repetative.

Either way once you're finished you should be able to export the table with the calculated costs.

Lastly I'm afraid I haven't any experience with Python scripting GRASS, but there's a nice article on the GRASS Wiki.

Hope this helps!

  • would something like python's networkx work instead of grass?
    – dassouki
    Sep 23, 2010 at 10:02
  • Potentially, yes - you could use some of the Shortest Path tools in NetworkX (networkx.lanl.gov/reference/algorithms.shortest_paths.html) to calculate between the nodes, but you'd need to get your OSM network into Python. Perhaps using the OGR Simple Feature Library to read in the data would work, but someone else might be able to offer an easier alternative.
    – om_henners
    Sep 24, 2010 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.