[out:csv(…)] returns a table: one row per element and one column per field you list. It is the fastest way from Overpass to Excel, Google Sheets or pandas.
The query
[out:csv(::id, name, stars, "addr:street", ::lat, ::lon; true; ",")][timeout:60]; area["name"="Genève"]["admin_level"="8"]->.a; nwr["tourism"="hotel"](area.a); out center;
Run it
Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).
How it works
- The list in
out:csv(…)names the columns: tag keys, or special fields like::id,::type,::latand::lon. - Quote keys with a colon, like
"addr:street". trueprints a header row;","sets the separator (the default is a tab).- With
out center;,::latand::lonare filled for buildings too.
Variations
- Load it in pandas:
pd.read_csv(url_with_query). - Other metadata fields:
::user,::version,::timestamp.
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.