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

Query multiple values for specific tags

0

Hello,

I'm trying to query all the "mall" and "department_store" for the key "shop" using the Overpass API and the following query:

[out:json];
area[name="London"];
nwr['shop'='department_store'](area);
out center;
nwr['shop'='mall'](area);
out center;

This however gives me only department_store because I put it first. So, basically it returns only the first shop I ask.

I also tried with the pyrosm package from Python. When I query for all shops it returns around 3330 records, but when I query to get both all shops and some amenities the records are less which doesn't make sense.

Any help please? :)

asked 19 Feb '21, 12:27

Katerina_Kourou's gravatar image

Katerina_Kourou
26445
accept rate: 0%

edited 19 Feb '21, 13:01

scai's gravatar image

scai ♦
33.3k21309459


One Answer:

4

The result of the first shop query is stored in the default set, which the second query is written to use for the search area. Storing the area results to a named set makes it available for multiple queries:

[out:json];
area[name="London"]->.search;
nwr['shop'='department_store'](area.search);
out center;
nwr['shop'='mall'](area.search);
out center;

In general, any statement without a named result set is stored in the default set, and any statement that takes an input (like area) will use the default set if a named set is not specified.

answered 19 Feb '21, 13:03

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

edited 19 Feb '21, 13:44

This worked! Thanks a lot :)

(19 Feb '21, 15:04) Katerina_Kourou

Source code available on GitHub .