How to effectively delete ways in JOSM without removing nodes belonging to other objects/relations

I am trying to remove some old proprietary/conflicting data as a part of a local community campaign initiative, and I cannot figure how to effectively delete ways in JOSM without downloading the whole country.

I have tried to download the data via an overpass query but kept getting warnings of missing referred objects after I deleted the conflicting ways and tried to upload changes.

Next, I compiled a list of ways and nodes IDs from the overpass JSON result, and used the download object function, chose mixed, and passed the list of IDs separated by commas. Now JOSM keeps complaining about node resolution conflicts when I tried to upload changes.

I thought I could just give a list of object IDs that need to be deleted, and JOSM would automatically remove parent relations, and keep nodes that are attached to other objects.

Any pointers would be much appreciated.

1 Like

Hi, you could try something like this in your Overpass-query:

[out:json][timeout:25];
way["highway"="primary"]({{bbox}});

(._; >>;);
(._; <<;);

out geom;

This should recurse down and add all nodes of the input ways (in this case primary roads) to the default set. Then it should recurse all the way up to select all ways and relations that include these nodes and add these ways and relations to the default set as well.
So in theory this should download everything that could have any connection to the way you are trying to delete.
Check out chapters “Recurse down relations” and “Recurse up relations” here: Overpass API/Overpass QL - OpenStreetMap Wiki


Another possibility is to use the “Download along way” feature in JOSM:
Help/Action/DownloadAlongWay – JOSM
This will download all data around the selected ways.

1 Like

Once you’ve downloaded the data in question (using overpass in this situation is going to be a bit iffy IMHO), use a JOSM filter/search expression to select the objects see Help/Dialog/Filter – JOSM and JosmFilterDoc/filter.md at master · simonpoole/JosmFilterDoc · GitHub The filter should restrict the nodes to those that have one parent way ways:1 This will naturally only work if there are no nodes shared between ways that you want to delete.

Press Delete :slight_smile:

1 Like

Another possibility is to use the “Download along way” feature in JOSM:
Help/Action/DownloadAlongWay – JOSM
This will download all data around the selected ways.

+1, when you load the data into josm, select the ways and use download along ways, eventually adjust the parameters to load data in a less wide corridor. Never delete objects if you haven’t downloaded the data because you will likely get conflicts.

2 Likes

Thanks for your quick help! Loving the quality of the community replies :smiley:

The recursive statements worked great.
Download along way seems to be a good alternative too.

I usually select the object that I’m concerned about conflicts for, and then use the Download Along… feature to get everything that might interfere.

Depending on the number of objects Download parent ways and relations might be another option.