Simulating traffic movement / pedestrian movement

Hey guys!

I'm a university student that is developing an open source software that can make people simulate their cities from real city data. The problem is that I do not have any idea how to simulate all these pedestrians / cars moving around following a pattern in a time lapse(depending if it's a student or a worker for example).

I tried to do at first the map graph so we can set points and routes but I do not really know if that's the way I have to start, something similar to this example :

I would like to do something similar to this : .



  • Answer ✓

    The problem can be split into two parts

    1) modelling the city data (roads and intersections etc)

    2) collecting the movement data and displaying it

    If you are planning to do a real city then (1) is a huge task and you might look for online services to get the data which might also provide API that might help with the visuals in part 2

    Alternatively you might look at the AI for 2D Games library some of the examples might give you some ideas.

  • edited August 2017 Answer ✓

    Ad 2) Do you have those data? Can you post some 20 lines of them here (format them as code please).

    Do they contain gps data? Then maybe unfolding map or so could be valuable for (1)

  • Hey guys! Thank you for the quick answers.


    You are right, that's what I have to do. I was thinking about building a graph and then build the routes (I'll do it manually at first). The problem is animating the cars and everything, but looking at AI for 2d games might be a good solution.

    I forgot to mention that I'll display everything following the Lévy flight (more information here):évy_flight

    I do work with the City Hall of my city so I'll be able to have all that information.


    I'll be able to have this data in few days, as soon as I have it I'll post it here. The data consists about how much people/cars pass per minute (on every street), and from that data I'll have to build routes following the Lévy flight. They might lend me more information, but I still don't know.

  • Answer ✓

    I am interested to hear more about how Levy_flight applies to your situation. I mean, how do you apply the concept using the data you talked about, what metrics it outputs and how would you use those results. Very interesting stuff.


  • edited August 2017

    Hey kfrajer! It's in fact really interesting, but it gets really complicated in terms of simulating the whole city movement.

    First you have to think what you want to simulate, in my case are pedestrians and cars. Cars and pedestrians move different and also at different speeds. Lévy flight is just a model of simulating the movement of the people (usually people move a lot in an area and then they take a huge walk and then walk in a certain area), here Daniel explains how it does work:

    With that being said, the way I'll have to apply all this amount of data into simulating is somehow linking and actually making routes that makes "sense" in terms of Lévy flight. Having a walk in a certain area, and then a huge walk, and then having a walk in a certain area (HOURS WILL MATTER ! so that's another thing to count, if he's/she's a student or a worker, if he/she works in city or outside the city, etc).

    I'll keep this post updated with all the info, but I would like to know ideas from you guys, I know you are really smart.

  • Hey! I'll update this post just for make you know what I've been doing to solve this problem. I used Mapbox gl js & Turf to make the simulation happen. Here's a little video (I have to add more objects):

  • Looking good =D>

  • Congrats! really looking forward to seeing the "more objects" update.

Sign In or Register to comment.