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

How to uniquely identify a location from OSM?

1

If I want to store an identifier to a particular location in OSM, what's the best way to do this please?

For example:

If I want to store the link to Hyde Park, I can use this: Way: Hyde Park (372975520) https://www.openstreetmap.org/way/372975520

Whereas if I want to store a link to Wimbledon Common, it's listed as this: Relation: Wimbledon Common (4285108) https://www.openstreetmap.org/relation/4285108

Note that one is a Way and the other is a Relation. Are these numbers still useful as UIDs? Or should I be storing the ID and the type (Way/Relation etc)?

Any guidance appreciated!

asked 02 Jan '20, 11:24

ab76555's gravatar image

ab76555
31113
accept rate: 0%

For completeness, if you just want to store a link to a location, you can store what's in the browser URL (for Hyde Park at zoom 15 that's https://www.openstreetmap.org/#map=15/51.5070/-0.1729 ). That's not linking to a particular object in OSM but is linking to a location.

(02 Jan '20, 11:31) SomeoneElse ♦

Thanks for the quick reply! What if I do want access to OSM object too? For example, if I've got a database that stores locations alongside ratings (which I'm accessing through my API), and I occasionally want to access the OSM object (for example, I might query my_location_id/osm_object_coordinates).

(02 Jan '20, 11:47) ab76555
1

escada's answer covers the aspect of permanent linking. Regarding your question about the way and relation IDs, each object type has its own numbering. That is, there's a node #1, way #1, and relation #1, all representing different things. So, to identify an object using its ID, you'd also need to record its object type.

(02 Jan '20, 17:22) alester
1

Brilliant - thanks all for your help. That's great to know about the node/way numbering!

(03 Jan '20, 09:25) ab76555

One Answer:

4

Since IDs can change, there is no definite solution. There are some workarounds (e.g. using Wikidata) listed on the wiki page Permanent ID

answered 02 Jan '20, 13:44

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

edited 02 Jan '20, 13:45

Source code available on GitHub .