OSM Road Data to Curve Network to Traffic Density Study

This has puzzled me for a while. Getting OSM data using plugins like Gismo is really interesting but it can be difficult to process the curves into networks to do further work on. I would love to be able to turn OSM road data into a curve network that could then be used to show traffic density if each node could be given a weighting representing population size of the town at that road junction and then the curve network given a colour gradient or thickness to represent traffic volume.

The problem with OSM road data is that it can give lots of curves that are actually one road. You can see in this image, the dual carriageway with roundabout and sliproads are lots of curves whereas I just want one curve with nodes to represent the network:

If I use a component like Flexibility’s Capture I can export a bitmap that starts to rationalise these curves. It would be much nicer to be able to capture specific areas rather than the viewport:

I was hoping to then use Rooster Rooster component to turn this back into curves but it picks up the edges rather than the centre of what were the roads:

Kind of cool, but not what I want!

This has cropped up on here before:
Simplify OSM Street Edges

The process I’m aiming for is like increasing the thickness of lines so that close curves merge together. Can edge bundling do this but keep to the original road layout instead of smoothing the curves? To get something like this from OSM road data, but merging curves:
https://discourse.mcneel.com/t/from-edge-bundling-wooly-paths-to-surface-between/50253

Let’s assume I do manage to get a nice clean curve network representing the roads on a map. (I will try and create an example file manually to experiment with) My next step would be to add values to nodes representing population size (or a weighting for traffic) and then look at shortest paths between all the nodes summing any weighting values to create a colour gradient or curve thickness to visualise traffic density.

The Edge Bundling discussions seem relevant to this, but not quite what I’m after. I don’t want to smooth the curves, I want to be able to create a visual indication of traffic density on top of an actual map of the roads and then be able to see what changes if a road was closed or a new road was built.

Any thoughts on this would be appreciated!

Here’s example OSM Road data:
OSM_Internalised.gh (2.6 MB)

If you have Flexibility and Rooster already: (remember to change filepaths to suit your PC)
OSM_Flexibility_Rooster.gh (2.6 MB)

An attempt to add traffic density to a line network with node weighting:
TrafficWeightingShortestWalk.gh (7.9 KB)

Can someone check this for me please?

I’m pleased with it but I can’t tell if it’s actually working as it should do… Looks great though :smiley:

So I think it is looking at all the shortest walk paths between all the nodes in the network and weighting each segment in that path based on the smallest circle at either end of the path.

So if path1 has a circle of rad 10 at one end and 30 at the other it weights each segment in that path with 10.

It does that for every path and adds up all the weightings for each segment. Then it colours the segments based on their weighting.

TrafficWeightingShortestWalk.gh (13.9 KB)

Just need to figure out how to get the OSM data into a line network and add the weightings!

the Topologizer component automagically translates lines into a graph, and also offers a simplified graph that collapses long branches into short ones (by removing “useless” nodes)

for instance, tested on a very small portion of your original file:

in red the actual graph, in white the simplified graph:

I don’t know if the simplified graph could be useful or not:
on one side, simplifying the graph in such a way only “road intersections” are accounted for as nodes, for sure can be helpful as it shortens the amount of iterations you need to traverse it
on the other hand, as you clearly mentioned you want to integrate population/traffic density data in the graph, then you might also need a number of “mid-points” nodes to distribute those weights onto?

as a side thought, for stuff like this I think that actual “geometric data” like curves and stuff should be used only at the very beginning to extrapolate graph nodes and vertexes, then you can put curves aside and focus on the graph data alone, which is mainly a data tree of integers (then it depends how you deal with Weights) in such a way to make things much slender and incredibly faster, for this reason this is usually done via code, and just take the adjacency matrix + weights from your geometry

example of FOX plugin, which also has some components for BFS and DFS (but also Ngon has some, and many others)

OSM_Internalised_Re.gh (39.0 KB)


Regarding your last post with the mesh example, I tried to reproduce the same thing just looking at the textual description, without actually following the code you have created, but I’m getting slightly different results here and there (what my eyes see as different I marked with a red dot, but I might have missed a few :D)
I think I haven’t understood well the way you use weights

TrafficWeightingShortestWalk_inno.gh (26.9 KB)

[edit] on a side note, linked to what I wrote at the beginning of this long post, the example you just did here with Delaunai Edges would be much closer to the simplified graph from Topologizer, as for each node there are always 3 edges (until it’s the mesh boundary)

2 Likes

Thanks for this, I will digest it all properly later when I’m back at the desktop.

The reason I want to be able to work with the original curves from the OSM data is so I can show colours on the actual map but I see what you mean about doing it more efficiently in code with just numbers… If only I could code :weary_face:

When I reduce the network to just 3 nodes (i.e. just 3 points of a triangle) it doesn’t seem like the colour coding is correct all the time. I need some more time to test it though.

Edit: I should probably pin the weightings number values to the mid point of the line segments to see what the difference is between my results and yours.

Your solution looks more right than mine! If I look at just 4 nodes mine can’t be right. The more nodes there are the more similar the solutions. It’s hurting my head trying to work out what’s going on so I think I will just adopt your solution :slight_smile:

I still need to work out how to go from the OSM Roads input to a useful line network. Using topologisers is a good idea, but there’s another stage before that rationalising all the lines.
If you look closely at the lines representing the dual carriageway, I need to turn this into just one line with nodes at each road junction…

here I transformed the weights into integers, so I did a rounding that was not necessary (correctly reverted into floats in the attached file)

I did a sort of fast visual readycheck :smiley:

TrafficWeightingShortestWalk_inno_check.gh (31.5 KB)

just for the sake of visually checking I activated “integers only” for the random generator, and deconstructed/oriented all the single paths in such a way for each iteration only the current path is visible, all the weights are always visible, and the weight assigned to each path is in white in the middle of each path:

is this the correct way you wanted it to be? like for each path it checks the weight only at the path start/end points, and then assigns to each segment of that path the same minimum value among those two weights?

I have no experience with OSM data, do those multiple cariiageways roads come as a separate set of data or different layer, in such a way it would be possible to isolate them somehow, and eventually use something like cull duplicate points (average-mode)?

Thanks for your effort on this.

My logic on the paths was to look at the weighting at the start and end of every path and take the smallest. Add this smallest value to every segment along that path. Do this for every path and accumulate the weightings for each segment.

So in real life (I know this is not accurate, but it’s an indicator)..
Imagine 2 towns, A and B, joined by a road network of segments.
A has a population weighting of 100 and B = 50.
There’s 50 opportunities for journeys from B to A because there’s 50 people who might make a journey from B.
There’s 50 opportunities for journeys from A to B because there’s 50 people to go and visit in B.
This is why I picked the smallest, but we could use the average of the 2 or any weighting based on other factors. It might also be useful to set weightings based on distance from attractor points or any other rules.

What actually happens in real life is that there might be many more reasons for travel between two nodes but giving each node an arbitrary weighting is a start. Its being able to sum all the weightings based on the shortest paths between all the nodes that is important. And I think that’s exactly what you’ve done, thanks!

There will be lots of conditions in real life, like some roads might be one way and some might be avoided for some reason even though they are on a shortest path. I am not considering constraints like this at this time although it would be really useful to be able to indicate if some roads were one way!

I’m interested in answering a question like… “What happens to traffic density if this bridge fails / road is closed / new road is built etc?”

We have had a bridge here get washed away in a storm a few years ago. I hear people say that this has caused increased traffic on certain roads but I don’t think it is significant so I want to investigate which parts of the network would be impacted by the bridge being removed.

It would also be cool to look at just how much do I have to increase certain weightings before there’s a significant impact elsewhere.

Your checks seem to show it is working perfectly!

OSM Data:
The original file I posted is what get’s output from Gismo plugin for roads. There are loads of layers of map data - roads, rivers, trees, buildings etc etc.
I think it comes from maps so it is lines curves and points derived from maps.
People face challenges in processing this data. For example if you take buildings, it gives the footprint of the building but not necessarily the height. In the instances where you do get height information, it doesn’t tell you what sort of roof the building has (flat, gable etc) There are topics on this forum where people are trying to automate the construction of 3d buildings from the OSM Map data.

I want to automate (as much as possible) taking the OSM road data and creating a line network or graph. So starting with the OSM curves I posted originally and getting a line network that can be plugged into the traffic weighting. Ultimately being able to show the original map colour coded by traffic density estimate!

This might simply not be possible and maybe I need to think of an easy way to draw the line network on top of the OSM road data manually.