Are OSM IDs unique over all Object types?

Meaning, can a way-ID occur as a relation-ID or a node-ID as a way-ID?

2 Answers 2


Osm_id is unique only within object type. It is easy to test with the following links



The current OSM statistics show these numbers:

Number of nodes     2412050198
Number of ways      241029453
Number of relations 2658037

Whole lot of the oldest nodes have already been deleted and generally new node ids are much bigger than new way and relation ids. Because of this it is more and more uncommon to find same osm_ids from a small extract but it can still happen and user must not trust that osm_ids are universally unique.

  • Hm but seems this id is only available as relation?
    – wutzebaer
    Jun 29, 2014 at 9:22
  • Because the examples are bad. Nevertheless the ID is just unique within the element type.
    – scai
    Jun 29, 2014 at 12:49
  • ok where do you know that? i couldn't find neither any example in my osm file nor any documentation about it
    – wutzebaer
    Jun 29, 2014 at 14:59
  • 2
    I edited my answer and corrected the examples to show a real way/node case that exists today and explained why such cases are rather uncommon in small osm extracts. The ultimate documentation is the ruby on rails schema wiki.openstreetmap.org/wiki/Rails_port/Database_schema
    – user30184
    Jun 29, 2014 at 15:17

Every OSM object follows this coding scheme in order.

  1. Type of object (node/way/relation)
  2. Id
  3. Version of object

so if the type is different then two or more objects can have the same id and they will refer to different objects. But if type and id are same and version is different then it represents different versions of the same object. In the osm api, version is optional and if not specified then the highest version is returned.

  • 6
    It might be better to say that an unique osm object can be identified by the first three. I suppose that editing tags creates a new version.
    – user30184
    Jun 28, 2014 at 18:09
  • 1
    Adding members to ways and relations also creates a new version, but moving nodes (even making a straight line of them) does not create a new version for the way.
    – AndreJ
    Jun 28, 2014 at 18:17
  • 2
    Yes, editing tags creates a new version and that part is done by the osm api. As for database the tags are also part of unique id. But we only use the api, so the first three will give unique object.
    – neogeomat
    Jun 28, 2014 at 18:20
  • could you give me an example where an id is used for two object types at the same time? I couldn't find any... Or is there any documentation about it?
    – wutzebaer
    Jun 29, 2014 at 12:24
  • The example is given in the other answer
    – poshan
    Jun 30, 2014 at 4:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.