Simulate the transportation on the map using Julia

I’m doing a project, part of which requires to simulate the transportation on the map of a certain area. After searching from the internet, I found the following two links related to map data simulation/visualisation.

I was wondering, are there useful updates as it’s already 2019. The other option is to write the code using Python and then execute these code using Julia. I, of course, really enjoy Julia and would like to see if it’s possible to do everything in Julia. Any comments are greatly appreciated.

The title of this post doesn’t seem to correspond with the question. Are they related?

I have updated it.

If you are using OpenStreetMap then you might consider + In particular they were designed to support visualization of agent-based simulations on maps. There is a scheduled presentation of these packages on Jan 17, 19 @ Fields Institure by @pszufe if you would have a chance to participate, see here for the details.


Thanks, bkamins. your suggestions are very helpful. I’m checking on those two packages. Probably can not go for the presentation though.

I tried the two packages. They work really well. The only thing is, it takes a huge long time to run. I think it’s because of the huge size of the input Open Street Map (.osm) file, which is like 1.5 GB. (“crying…”) Is there a better way?

@bsnyh use the OSMFilter ( utility to filter out unnecessary information from the .osm file (there is really lot to filter out like contributor name or not-road-related data).

Moreover, note the loading time is long only for the first time. With the default settings the OpenStreetMapX creates a *.osm.cache file that keeps a copy of the Julia object representing the map (using the serialization mechanism).

This library is currently under further development and you are welcome to comment/propose features.


Thank you. I will definitely contribute if time allows.

I’m not sure this is what I need. Sigh. Can anyone help me? Is this because of the format of the .osm file ?

Hi @bsnyh,
it would always be easier to help when you provide the source code.
However, most likely, you have either:

  • accidentally filtered out road information from your *.osm data
  • use white color for plotting roads

If you post the code and provide a link to some (perhaps smaller) file I can help you.

@pszufe, thank you so much for your help. I plan to do some animations in the above generated image, like the movement of a car etc, and maybe show some nodes/points of interest, and show the selected route. Do you have good recommendations? I did not do much with the code. Just plug in the input file and call two functions. will paste the code here soon.

using OpenStreetMapX
using OpenStreetMapXPlot

map_data = OpenStreetMapX.get_map_data("/home/devel/Desktop", “v.osm”)
OpenStreetMapXPlot.plotmap(map_data.nodes, OpenStreetMapX.ENU(map_data.bounds), roadways=map_data.roadways, roadwayStyle=OpenStreetMapXPlot.LAYER_STANDARD, width=3000, height=3000)

not sure how to pass part of the .osm file to you. Could you kindly let me know?

Regarding the animations on maps there are two options:

  • use animations API from Plots.jl
  • use OpenStreetMapX to process data required for animations (nodes, lattitudes, longitutdes) and use a seperate library such as leafletjs for vizualization. The problem is that LeafletJS.jl seems to be unmaintaned. However leafletjs works like a charm from R and there is no problem with working with the OpenStreetMap nodedis

The second approach could be more robust but seems to require development export.

Note on sharing the OSM file: go to , click “Manually select the different area” and now on the “Overpass API” link right click and select “Copy link location”. Another option is just uploading the OSM file somewhere (e.g. to GitHub pages).

@pszufe, thank you so much. Please see the following link for the .osm file. test.osm. I have tried to convert / delete some not useful information from the original .osm file. is the zip version of a part of the .osm file I got finally after conversion. Thank you again. If you know a good way to get only the road-related information from the file, please let me know.

@pszufe, I’m very eager to learn. :wink:

Your test.osm file is not readable (the contents seems to be corrupted)

You should test your osmfilter command on some smaller files and find a set of parameters that work. Check the filtered output files on some external software such JOSM (your osm file cannot be opened by JOSM).

Here is a sample osmfilter command:
osmfilter mymap.osm --keep="highway=motorway highway=motorway_link highway=trunk highway=trunk_link highway=primary highway=primary_link highway=secondary highway=secondary_link highway=tertiary highway=tertiary_link" -o=mymap.osm

Once you find a set of osmfileter parameters that seems perfect for routing (for your case) - paste it here so others can see it.

Last, but not least - it would be better if you could describe a set of repeatable steps (starting from the export link described by my previous post) rather than using your own files. It seems that there might be problems that your data does not conform to the OSM standard and it is not a Julia-related issue (and probably might need a discussion on OSM forum).

1 Like