Overpass query example

Cafés near train stations

Search around the results of another search: every café within 150 m of a station. Example: Zürich.

around accepts a set instead of a single point. This finds features near other features, for example cafés close to stations, or schools near main roads.

The query

[out:json][timeout:60];
area["name"="Zürich"]["admin_level"="8"]->.a;
node["railway"="station"](area.a)->.stations;
nwr["amenity"="cafe"](around.stations:150);
out center;

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. The stations are saved in the set stations.
  2. (around.stations:150) keeps cafés within 150 metres of any station.
  3. Only the cafés are printed. Add .stations out; to include the stations.

Variations

  • Around lines works too: way["highway"="motorway"](area.a)->.m; nwr["amenity"="school"](around.m:200);.

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 →