(Semi) automatic combining highway pairs. Any suggestions?

For various reasons highways in the Netherlands are split into segments but very often 2 joining segments have exactly the same tags. In many case there is no reason to have these segments split. In the last 6 months or so we’ve been combining/merging these highways manually (>85.000) using JOSM. See this map with examples (but be patient) that can be used as a WMS in JOSM. Currently I can make a selection of highway pairs that can be combined (key=C in JOSM) without any problem whatsoever. We can keep on doing this manually but this still is a lot of work so I am looking for a way to (semi) automate this. So input is a (long) list of (high)way pairs (derived from a postgis script). Is there any clever /semi automatic way to merge these pairs?

Example of a few pairs:

7436419, 7436483,
7436021, 1136248480,
7436424, 7436429,
7436274, 7436299,
7436006, 7436057,
1025984692, 1025984693,
7435801, 232961439,
7435920, 7436036,
7450227, 7450254,
7450188, 7450257,
7450258, 9087289,
858734016, 858734038,

you also need to take relation membership into accounts, especially in a case of running a bot


You are right and that is all taken care of. The script that identifies ways that can be connected has evolved over quite some period and manually combining these ways has given us some good insight aswell.

Writing script doing this is definitely possible and not terribly hard, especially when you skip cases that require reversing ways.

Not aware of any already existing tool.

If it’s a script working through them then I think this triggers the Automated Edits code of conduct?


I agree. Currently I see this as the ideal situation:

A hundred pairs (or so) of highways will be loaded into JOSM using an overpass query containing these highway id-s. JOSM would loop through these and combine these ways. If anything is wrong with combining JOSM will give an error (but I am very confident this wil not happen :wink: ) After looping through these pairs the changeset can be uploaded to OSM.

What is currently missing is a plugin looping through highway pairs and combining them (key: C). Or maybe there is an other solution.

If there is a technical solution I will inform NL community of this plan before I/we will execute the plan on a large scale.

depends, for example if someone actually reviews every single edit (needed anyway for the first 500 - 5000 edits to detect bugs) then no.

that is an automated edit

1 Like

I can understand why you would like to combine pairs. But I don’t understand why you are looking at only pairs and not triplets or more.
It’s not logical to look at pairs only.

Secondly, I remember one of the Dutch mappers that imports roads telling he or she allways imports roads in seperate pieces because with those pieces it would be easier to create route relations. This should be adressed. It would be stupid to import thousands of pieces in the database and afterwards have a script combining them.


But then, if you let the script rerun until no more pairs are found eventually all roads will be combined :slight_smile:

But what to do when there are multiple combinations possible? How to distinguish between main road and branches?

The script distinguishes in situations of possible combinations. This situation is definitely not one that will ever be solved (semi) automaticity. A local mapper might know best if a combination (and which one) is best.

In NL no roads are imported. Many years ago the Dutch road network was imported from the AND database. In this database a road consisted of many segments (just like the Dutch National Road database (NWB)). One for each connection with an other road. All segments had an own AND id which was also imported in OSM at the time. Later on we realised these AND id’s were of no use at all and thus… were deleted from OSM. We also realised that we would never have roads split in so many segments if they were manually mapped. All these segments also have consequences for some data consumers. Nominatim returns all these segments if you search for a street in a city. (try Marianlaan Zwanenburg e.g.) and Carto shows a lot more street name labels when there are many segments.

It is also good to realise that not all segments were created by AND import. A lot were created for reasons unknown to me. Maybe an error in an editor. Or maybe a way was cut because only a part was surveyed and a mapper wanted to add a tag (e.g. surface=asphalt). When someone else later also adds this tag to the other part we end up with a split way for no reason at all. During the 90.000 combinations we’ve already made we’ve also seen many very small segments (often no more then 1 or 2 meters) that were very easy to miss when working on route relations.

As far as I know consensus in OSM is that highways are not split unless tags differ or when (route) relations requires us to do so. Also for consistency reasons in OSM it would be a good idea to combine ways. Also see this response in the Dutch forum regarding route relations.

For further information please also see this thread on the (old) Dutch forum.


Oh, opinions must have changed then (not your opinion).
I remember Marc Zoutendijk writing that combining roads was a strange habit of sick people.
Here is the old thread.

1 Like

I also fail to see the benefit of this. What’s the actual reason people would do this? Did anyone complain that the total number of ways is too high? Are we trying to solve an actual problem, or what?


I definitely see a benefit because in lots of places streetnames are not shown at all because there is not enough space to show a name ten times in ten centimeter. I brought this up in the rendering section of Carto and it was picked up by someone but it stranded there also.
I can’t find that thread.

As an example: on this long stretch of road the name is not shown because it doesn’t fit four times:


Yes I guess so. I think the issues with cutting highways (with relations) in JOSM has disappeared so that there no more reason not to combine highways. As stated by Dick who maintains a lot of the route relations in OSM it would even be beneficial to now have these ways combined.

1 Like

I can understand this question because the current situations has not lead to major problems (AFAIK). Ok …rendering streetlabels in Carto could be better but it has never been a major issue. The question one might ask is … how should we map a long street with many connections to other streets? (not considering differences in tags/route relations). Should we map one long way, or all segments between connecting ways, or something else? As far as I know most people would map just one way. This will not prevents us from eventually ending up with segments that could be joined (again) because mapping continues. Then the question is …. should we join these again or leave em alone? Answers will differ depending on who you ask.

The same goes for ways that are split without any other connection ways on the node where ways are split.

I personally see split ways as a kind of database redundancy. The DB of the current situation in OSM could be smaller if ways are joined.
Furthermore creating/maintaining route relations is more transparent.
And as said before … streetlabeling in Carto will improve

Again one might argue that this is not worth the trouble. In that case … don’t do it and save your energy for other OSM related work that you find more important. :wink:

I have (manually) merged some cases where for some reason road was split into about 100 elements, each about 1m long. This was making editing it a pain.


I’ve seen many crazy split ways and often wondered why they were split in the first place. One common situations is where ways were split because there was a bridge=yes. Later on some saw it was not a bridge but a crossing tunnel=culvert and removed the bridge=yes. And forgot to combine ways again. I’ve also seen many ways that are split of which one part was 1 meter long but I’ve never seen something as crazy as a way split into 100 segments of 1 meter each.

1 Like

There is a handy key right to the left of the [End]-key that can take care of that.
And then draw something new in seconds.

Anyways, we’re still looking for a software solution to the combining task.

@PeeWee32, do you have a changeset number I can have a look at of some of the 85000 roads you combined?