Undoing deletions

From OpenStreetMap Wiki
Jump to: navigation, search

This article describe undoing deletion. Please refer to article Change rollback for general rollback.

Before undoing edits of other users please try to contact them first.

Undoing deletions while editing

In general you can undo any kind of accidental editing mistake, including deletions, by pressing Ctrl+Z (in JOSM, Potlatch or Merkaartor). This gets used a lot by even the most experienced OpenStreetMap contributors.

But what if you've done an upload?

Undoing deletions after upload

So, you deleted a large chunk of the map, and then uploaded by mistake?! What can be done to get the data back on the server again?

Method 1: Use Potlatch 1 revert function (easy!)

See Potlatch 1/Primer#Undoing mistakes

It is not possible to undelete objects using Potlatch 2.

Method 2: Use JOSM revert plugin (also easy!)

See JOSM/Plugins/Undelete

Method 3: I have a copy saved from before I deleted stuff

This method assumes that you are using JOSM, and that you have a saved copy of the data on your local machine (let's say, "data.osm"). When you saved the data is important. If it was before you deleted the items, then this is the easiest to recover. If it was after you deleted the items, but before you uploaded, then it is still possible. If the only copy you have is after you uploaded, then you cannot recover using this method

There is an important lesson here: as with any computer application, save locally as you go along, as well as uploading to the central server.

This should be fairly straightforward to recover. We want to tell the server that the items IDs that have been deleted are now modified. This will undelete them on the server.

1. Start JOSM and download the affected area from the server. You can do this in small areas if you like.

2. Load your "data.osm" from the local disk. Hopefully you will now see all data back again.

3. Try and upload. Nothing should be available for upload, but if it is you will need to work out what it is and whether you really want to upload it.

4. Use the select tool to select the area that was affected.

5. Add a new tag to all this data, that does not clash with any existing tags. Maybe something like "ignore=me".

6. Delete this new tag. All items you added this tag to are now marked as "modified" in JOSM, and are candidates for upload.

7. Upload the data.

8. Restart JOSM and download the affected area to check it has uploaded correctly.

9. Repeat from 1 for any additional areas that need to be corrected.

Warning: this will set the items that you upload to the server to be the same as you have on disk. If your local copy is quite old, then by doing this you may revert changes that other people had made to the data on the server. This is another reason to keep saving locally as you are editing!

Recover deleted Relations

Method 1: Manual recovery without tool support

As the current tools provide no easy way to recover a deleted relation this is a bit tricky. If you are not sure you can do this without breaking more stuff then ask for help on the mailing list.

For this example I'm using the relation 49903 for which I did a restore.

1. Open the history in the browser: http://www.openstreetmap.org/browse/relation/49903/history

1a. if the relation does have a lot of versions step 1. may fail with an error message like (sorry, it take too much time...). You can directly open a specific version by using http://api.openstreetmap.org/api/0.6/relation/<Relation ID>/<Version number>

2. Check that all ways of the relation still exist. If some of the ways are also deleted it's best to recover these first. Please be extra careful with this step. Had the ways been deleted for a good reason? Do more accurate ways exist? If so it might be a good Idea to use these in the recovered version instead. In my example this is the case.

3. Download the XML source

4. Open the file in a text editor. In my case the delete was in version 18, I want to recover version 17. I delete all old relation blocks, keep only version 17 and 18.

5. Replace the line with the relation tag of the version you want to keep with the most current one. Don't forget to remove the closing slash in case the last version was a delete.

6. Add the attribute action="modify" to the relation

7. As in my case some ways need to be replaced - so I also removed these entries.

8. Save the file and open it in JOSM

9. Upload your change in JOSM. Voilà, the relation is back.

10. In my case I now downloaded the relation members and selected new ways to fill the gaps the previously deleted ways had left.

Undoing other people's uploads

Now what if somebody *else* deleted your edits and you have no way of finding exactly which way/node/relation was deleted? Then you need to find that in the history, using something like the OpenStreetMap Watch List or other tools.