Tuesday 20 October 2015

python - Trip travel matrix on OSM data



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?



Answer



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!


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...