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

How can I get a list of all objects with a certain tag?

1
1

Xapi will give me such a list, but I have to download the objects themselves. For relations it's even worse: xapi not only gives you the relations but all the elements.

So how would I get, for instance, a list of all relations with network=US:US?

asked 16 Jul '10, 06:11

NE2's gravatar image

NE2
1.4k333954
accept rate: 9%


One Answer:

4

The API has a search method that you can use for this. The request to use in your example would look like this:

http://api.openstreetmap.org/api/0.6/relations/search?type=network&value=US:US

This is little known and little used because unlike XAPI, it does not support bounding box queries so you will always find all objects, world-wide, that match your request. (The same request works for ways or nodes if you replace "relations" accordingly in the query.)

This query will return the matching objects, but not referenced objects (i.e. no nodes in ways or members in relations).

The request is documented on the Wiki but for some reason it has not made it onto the API 0.6 page.

answered 16 Jul '10, 07:56

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Exactly what I wanted. Thanks :)

(16 Jul '10, 10:52) NE2

Now wait a second. I don't remember what happened yesterday, but I downloaded that query today and it's incomplete. For example, relation 112245 is missing.

(16 Jul '10, 23:50) NE2

Source code available on GitHub .