for groups the current set by an expression, and make creates a new element for each group. Together they work like GROUP BY in SQL.
The query
[out:csv(name, total; true; ",")][timeout:60];
area["name"="Zürich"]["admin_level"="8"]->.a;
nwr["amenity"="restaurant"](area.a);
for (t["cuisine"]) {
make stat name=_.val, total=count(nwr);
out;
}
Run it
Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).
How it works
for (t["cuisine"])loops over the distinct cuisine values;_.valis the current value.- Inside the loop, the set holds only the restaurants with that value.
count(nwr)counts them. make stat …creates a row; with CSV output each row is one line. The empty name counts restaurants without cuisine.
Variations
- Sort the CSV in your spreadsheet, or by value with
sort -t, -k2 -n.
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.text)
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.text());
Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.