Undeleting objects in JOSM before uploading

I made a pretty big changeset with lots of details, and I noticed only in the upload dialog that I mistakenly deleted a building I didn’t mean to.

So, is there a way to undo the deletion before I upload?

The plugin Undelete doesn’t help in this case, inputting the object ID results in nothing happening.

I’d rather not upload the changeset and try undeleting afterwards, I’d just want to undo the deletion while I’m editing. And I can’t get it back with Ctrl-Z, I need to save and restart JOSM due to an intermittent graphic bug.

1 Like

Directly with JOSM:

  1. Activate the expert mode:
    Edit → Preferences → Expert Mode (bottom left corner)

  2. Search for all deleted objects:
    Edit → Search
    Activate the “all objects” option.
    Search string: deleted

  3. The search results now show all deleted objects.
    Select the desired deleted object (the building).

  4. Then purge this object:
    Edit → Purge

It is possible to edit the OSM file directly with a text editor.
Search for the deleted building and its deleted nodes in the OSM file and remove the corresponding entries, these are marked with action='delete'.
To find out the IDs of the deleted objects, you can download the data again from the OSM server into a new layer in JOSM.
Just in case, it is better to make a backup of the OSM file beforehand.

Solution directly with JOSM, see my answer below.

One option would be to try and save the changes to a file, then open in a text editor. From there, search for the ID of the object you accidentally deleted, remove the section to delete it, and then save and open again in JOSM.

Of course, if there is solution before uploading, that’s fine. But is this really a big problem? Upload, with the error, download and fix the problem (add the building) and upload again. During a short period of time the map has an error, but it’s nothing to worry about.

1 Like