How to export with positive node ID numbers?

The data I’m using has negative node ID numbers and I’m trying to export it for use in Unity but the Unity plugin I am using only accepts positive node IDs. Is there a way I can export the data from JOSM with positive id numbers?

What do you want the positive IDs to be? Would it matter if they potentially existed somewhere else in OSM? If not, maybe perhaps just process the XML file with a text editor such as “sed”?


So I don’t want to change anything about the id numbers other than for them to be positive instead of negative. It shouldn’t it’s a locally stored city sized piece of proprietary data that’s not using any other OSM data. I tried writing a C# script to process it because I don’t want any of the other numbers changed just the ID’s but it wasn’t working correctly. It kept leaving off the ends of the lines.

All new objects (node/way/relation) get a negative (temporary) id-number assigned by the editor. When you upload such an object to the OSM-Database a proper (unique) positive id will be assigned.

So AFAIK there is no way to force JOSM to change these negative id’s to positive numbers. You need to process these files manually and must not upload these files to OSM-Database.


Yes, I’d underscore what @PHerison says: if you do have negative ID numbers, those aren’t really OSM data, they are OSM “proto-data,” meaning they are data in an OSM software editor’s buffer which have not yet been written into the “great OSM servers in the sky” (authoritative for OSM data). At the point they are “written into OSM,” all negative (buffered, temporary) ID numbers become positive. And those are the ID numbers that you should use.

So it seems whatever you are doing with your toolchain, you are trying to do something “one step (or more) too early,” that is to say, before the data truly “enter” OSM as a database. Save these data into OSM first (as if you had edited them, which is likely why they are negative, and now want to commit them to OSM with JOSM’s green “upload arrow,” for example), so the negative IDs become positive IDs, and you should be good-to-go.

Or, use a (sed, C#, awk…) script, but be careful what you are doing with those, as now you could conflict with what is actually in OSM.