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.

closed as too broad by PolyGeo Apr 13 at 21:49

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    IF I may ask, what is the objective of this exercise? Are you trying to develop a pedestrian activity based model? – dassouki Jul 27 '13 at 18:47
  • 1
    @dassouki- I am trying to simulate a criminology theory- Routine Activity, a part of which requires me to simulate random movement of criminal agents – user1628340 Jul 27 '13 at 19:05
  • There are tools that will create the intersections of crossing polylines. What software are you using? If you are looking to generate data (intersection points) you can try QGIS, in the Vectors tab in Analysis Tools you will find the the Line Intersections tool – Ryan Garnett Jul 27 '13 at 20:18

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.

  • @MappaGnosis- does the link for creating routable network you have given, take into account intersections among interior nodes of roads? Apparently it seems that it consider only intersections t start and end point of raods – user1628340 Aug 4 '13 at 4:51
  • It accounts for the start and end points of linestrings. If you have a road network with valid geometry (i.e. linestrings are split at all intersections) then the process will work. So, a road might be composed of several linestrings. – MappaGnosis Aug 5 '13 at 7:48

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