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

How to extract ids of all the objects in an osm file and show them in a list?

0

Hi everyone,

I have created around 100 protected areas in Iran over last few months, in order to complete the wiki page regarding these areas, I want to show them in a list with their name and OSM ids in the wiki page. Is there a way to extract Ids of objects in a .osm file? or even better is there a query which can be used to list object's Id based on a specific search criteria?

By the way I have tried Spatial Manger it shows all the tags except Ids.

Thanks

asked 13 Sep '16, 08:49

Adib%20Yz's gravatar image

Adib Yz
291101219
accept rate: 0%


One Answer:

3

Use overpass turbo and enter “boundary=protected_area in Iran” in the wizard. You'll have the data displayed on a map, and the corresponding json on the "data" tab. You can export that to a format of your liking.

Optionally, replace the "print results" section with "out ids;" so that only ids are returned (ignore the "repair query" suggestion). That might make parsing the data easier.

answered 13 Sep '16, 11:09

Vincent%20de%20Phily's gravatar image

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

2

Also, avoid linking to object id's whenever possible. See https://wiki.openstreetmap.org/wiki/Overpass_API/Permanent_ID

(14 Sep '16, 14:23) joost schouppe

Source code available on GitHub .