Overpass query example

Several tags at once (union)

Combine several searches with a union to find features tagged in different ways. Example: all drinking water sources in Zürich.

The same kind of place is often tagged in more than one way. A union, written as statements in parentheses, collects the results of several searches into one set.

The query

[out:json][timeout:60];
area["name"="Zürich"]["admin_level"="8"]->.a;
(
  node["amenity"="drinking_water"](area.a);
  node["amenity"="fountain"](area.a);
  node["man_made"="water_tap"](area.a);
);
out;

Run it

Running the query…

Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).

How it works

  1. Each line in the parentheses is an ordinary search. All of them use the same area a.
  2. The union removes duplicates, so an element that matches twice is returned once.
  3. Not every fountain gives drinkable water. To be strict, add ["drinking_water"="yes"] to the fountain line.

Variations

Run it from your code

curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
  --data-urlencode 'data@query.overpassql'

Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.

More examples

All examples →