Overpass query example

Metro lines of a city

Get the routes of a metro network with their geometry and colours. Example: the Paris Métro.

Public transport lines are relations of type route. Their members are the tracks (ways) and stops (nodes). out geom returns the members with coordinates, ready to draw.

The query

[out:json][timeout:60];
area["name"="Paris"]["admin_level"="8"]["wikidata"="Q90"]->.a;
rel["route"="subway"](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. Ten other places called Paris also have admin_level 8. ["wikidata"="Q90"] picks the French capital.
  2. rel["route"="subway"] finds route relations. A relation counts as inside the area when one of its members is.
  3. Each direction of a line is usually its own relation, so expect two per line.
  4. out geom; adds coordinates to every member. The colour tag holds the colour of the line.

Variations

  • Trams, buses and trains: route=tram, route=bus, route=train. See tram network.
  • Just the line names and colours: out tags; is much smaller.

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 →