Overpass query example

Tram network

Draw the tram network of a city from its route relations. Example: Zürich.

The same technique as for metro lines works for every kind of public transport. Zürich has one of the densest tram networks in Europe.

The query

[out:json][timeout:60];
area["name"="Zürich"]["admin_level"="8"]->.a;
rel["route"="tram"](area.a);
out geom;

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. rel["route"="tram"] returns one relation per line and direction.
  2. out geom; includes stops and platforms as members, too. Skip members with a role like stop or platform if you only want the track.

Variations

  • Only the tracks, without routes: way["railway"="tram"](area.a); out geom;.

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 →