Wednesday 21 August 2019

openstreetmap - Simulating Random Agent Movements along Roads on Map?




I need to simulate agent movements on map as follows:


Agent starts a known location and moves along a road. At each road intersection, the agent uniformly chooses one possible road and moves along that. The path chosen is to be traced with a poly-line.


I know how to choose a path uniformly and mark it with poly-lines once I have the data. But I am looking for how I can retrieve data like road intersection points and the roads leading from there on.




Answer



I have recently implemented a similar thing. You need a routable road graph. Have a look at underdark's tutorial on using PGRouting on OSM data. It will tell you how to set up a routable graph.


Once you have the routable graph you will have a set of nodes and a set of roads. The nodes correspond to the start and end points of the road lines. As your agent reaches the end of a road, identify the associated node id and then select from your road table all roads where the start or end node matches the node just reached, but exclude the current road which the agent has just traversed. Choose the agent's next road from your selection and note the direction of travel (i.e. is the current node at the start or end of the newly selected road). Then proceed until the next intersection.


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