What's the general algorithm to draw a road network of a certain area?


#1

Hi, this might be a naive question. But I would really appreciate it if someone can give me some hints. I was wondering, how do people usually plot the road network of a certain area in a map? Of course, certain coding function is called, but how? Thank you so much for your time and attention.


#2

You can checkout https://github.com/pszufe/OpenStreetMapXPlot.jl that is the plotting frontend of https://github.com/pszufe/OpenStreetMapX.jl and uses data from OpenStreetMap.

@pszufe is an expert here, so he might have some more advice to share.


#3

OpenStreetMapX.jl allows you to process data in Open Street Map format (if you do not know how to get this data - it is described in project website). In particular a map in OpenStreetMapX.jl is represnted as a LightGraphs.jl graph.

For plotting you can use OpenStreetMapXPlot.jl - this is particularly useful for coloring routes or marking nodes on the map.

For interactive plotting the best tools out there seems to be LeafletJS. There is a Julia wrapper for it LeafletJS.jl but unfortunately it is unmaintained. What I usually do to process map data/analytics with Julia and if I need interactivity I use R-Leaflet integration.


#4

I think I have tried the OpenStreetMapx.jl, with my osm map data. But the data is too large, and the map finally obtained does not look very good. Someone told me that I need to leave out certain information from the data, and eventually I tried the other way around, by using a python package osmnx and then tried to call this python function from juilia. I’d prefer to mainly use Julia though.

Is there a standard way to process the huge osm file obtained from the open street map website?


#5

Use the osmfilter utility first. I do vehicle traffic modellig/agent-based simulations and usually this command works for me:

osmfilter myfile.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 highway=unclassified highway=residential" --drop-author -o=myfileout.osm 

After running this command your file will be around 6x smaller.
Of course you might need different filtering depending on your needs.


#6

@pszufe, One more question. How did you actually draw the edges, I mean, what’s the underlying principle? What I understand is that, if it’s a straight line, then it’s fairly easy to draw, because we basically can know the location of each point along this line. On the other hand, if it’s a curved line, then how did you know the shape / function of the line to draw it? I hope this is not a naive question to ask. I think this has something to do with the open street map data format.


#7

Because I was thinking to model / visualize the movement of a vehicle along the road network. It would be much easier if each edge of the road network is a straight line, since in this case, I can just use linear function as the line/edge along any given two points. On the other hand, if it’s not a straight line, then things would be really complicated. I wonder how you handle this when you draw/plot the map.


#8

@bsnyh - have a look at OpenStreetMapXPlot.jl source code. There are straight lines - just a lot of them. You can easily use OpenStreetMapXPlot.jl to render images of animation frames (with vehicle location), than you can use some other tool to combine the frames into a movie.


#9

so, all of them are straight lines, not some kind of curves? If so, then linear interpolation would work.


#10

the frames you’re talking about, do you mean geo-dataframes?


#11
  1. yes they are straight lines and you can use simple interpolation
  2. I mean simply animation frames, you could generate subsequent frames, save the to files and combine into a movie.