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

Overpass API: how to get all the values from a specific key

0

Hello,

I want to get all the shops in London. I tried the query below, but it didn't work. Any help please?

[out:json]; area[name="London"]; node"shop"=*; out center;

Thank you, Catherine

asked 27 Jan '21, 21:54

Katerina_Kourou's gravatar image

Katerina_Kourou
26445
accept rate: 0%


One Answer:

1

There's a few ways to do this, but behind the scenes they do essentially the same job. Note 'node' won't return all shops so I used 'nwr' (nodes/ways/relations) I use:

rel[boundary][name="Greater London"];
map_to_area;
nwr(area)[shop=car];
out meta center;

shop on its own returns 20mb of data so I restricted it to car shops in this example.

If you want to display the boundary use this:

rel[boundary][name="Greater London"]->.LDN;
.LDN map_to_area;
nwr(area)[shop=car];
out meta center;
way(r.LDN);
out geom;

answered 27 Jan '21, 23:27

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 27 Jan '21, 23:28

Thanks Dave. I want though a way to get not only the category "car", but all the categories that are included in the shop. E.g. Supermarket+car+clothes etc..Eveything! Any way to do that please?

(28 Jan '21, 08:05) Katerina_Kourou

Remove '=car' There's a fair bit of info on the wiki such as this page: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example

(30 Jan '21, 23:02) DaveF

Source code available on GitHub .