This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Keep node/way IDs when copying a relation

1

I'm not sure if this is the right place to ask this, but figured there are a lot of people around here that are familiar with JOSM, so it can't hurt to try.

I am copying a relation to another layer so I can cut the file size down of the data I'm importing. However, when I copy the relation, create a new layer and paste it, the relation's ways and nodes all have an id of 0. How can I copy the relation while saving the original ids? Thanks

asked 21 Oct '14, 03:02

chillNZ's gravatar image

chillNZ
76338
accept rate: 0%

edited 21 Oct '14, 22:41

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


One Answer:

3

When you copy nodes and/or relations, they are new objects (and therefore have temporary id 0 until they get assigned their definitive id after uploading). I don't think there's a way around that, but you could use other techniques:

  • Delete stuff you don't want from the current layer instead of copying stuff you want to a different layer. You might find the search function (Ctrl-F) helpfull for that.
  • Edit the *.osm file mannually (in a text editor, with tools like grep, or even with osm parsing libs) to remove the bits you don't want, instead of using josm.

answered 21 Oct '14, 10:28

Vincent%20de%20Phily's gravatar image

Vincent de P... ♦
17.3k18152249
accept rate: 19%

2

Thanks, I had tried the deleting method but turns out JOSM doesn't like actually deleting the nodes and ways from the source file either. I understand why, but it means deleting the nodes does effectively nothing for me as the program I'm using still tries to parse the nodes with tag action=delete. After a bit of research I think I'll just use XMLStarlet to remove the deleted nodes from the file to reduce the import time.

(21 Oct '14, 21:58) chillNZ

Source code available on GitHub .