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
Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).
How it works
- Each line in the parentheses is an ordinary search. All of them use the same area
a. - The union removes duplicates, so an element that matches twice is returned once.
- Not every fountain gives drinkable water. To be strict, add
["drinking_water"="yes"]to the fountain line.
Variations
- A regular expression is a shorter way to match several values of the same key: see regular expressions on tag values.
Run it from your code
curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
--data-urlencode 'data@query.overpassql'
import requests
query = open("query.overpassql").read()
r = requests.post("https://api.overpass.ch/v1/YOUR_API_KEY/interpreter",
data={"data": query}, timeout=120)
r.raise_for_status()
print(r.json()["elements"][:3])
const res = await fetch("https://api.overpass.ch/v1/YOUR_API_KEY/interpreter", {
method: "POST",
body: new URLSearchParams({ data: query }),
});
if (!res.ok) throw new Error(await res.text());
console.log(await res.json());
Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.