Overpass QL Intro

Basics of OSM

OSM right click menu.
OSM tags after clicking Query features
OSM tags after clicking Query features.
Tags associated with an OSM object
Tags associated with an OSM object.

Basics of Overpass QL

Overpass Turbo site.
node[amenity=atm]({{bbox}});
out;

Give me all nodes that have a tag amenity=atm and are within the map I can see on the right side.

ATMs returned by our first query.
Searching for tags in a OSM database
Searching for tags in a OSM database.
Search results for “school”.
(
node[amenity=school]({{bbox}});
node[building=school]({{bbox}});
node[amenity=music_school]({{bbox}});
);
out;
node[amenity=school]({{bbox}});
node[building=school]({{bbox}});
node[amenity=music_school]({{bbox}});
out;
(
node[amenity=school]({{bbox}})->._;
node[building=school]({{bbox}})->._;
node[amenity=music_school]({{bbox}})->._;
)->._;
out;
node[highway=bus_stop][shelter=yes]({{bbox}});
out;
node[highway=bus_stop][name="Nazionale/Quattro Fontane"]({{bbox}});
out;
node[highway=bus_stop][name~"Fontane$"]({{bbox}});
out;
node[highway=bus_stop][name~"Fontane$", i]({{bbox}});
out;
node[!highway]({{bbox}});
out;
Go to results button
Go to results button.
[timeout:120];area["name:en"=Prague]->.a;
node(area.a)[amenity=atm];
out;
[timeout:120][out:json];area["name:en"=Prague]->.a;
node(area.a)[amenity=atm];
out;
Buttons for switching between raw data and interactive map.

Areas

area["name:en"=Prague]->.a;
node(area.a)[amenity=atm];
out;
rel["name:en"=Prague][boundary=administrative]->.prague_rel;
.prague_rel map_to_area->.prague;
node(area.prague)[amenity=atm];
out;

Examples

area["name:en"="Czechia"]->.cze;
way(area.cze)[power=line][voltage=400000];
(._;>;);
out;
400 kV power lines in the Czech Republic.
area["name:en"="Prague"]->.prague;
(
rel(area.prague)[route=tram][ref=3];
rel(area.prague)[route=tram][ref=9];
);
(._;>>;);
out;
Tram routes 3 and 9 in Prague.

Around filter

area["name:en"="Prague"]->.prague;
node(area.prague)[railway=tram_stop]->.trams;
(
node(around.trams:500)[railway=stop][!subway];
node(around.trams:500)[railway=station][!subway];
);
out;
Train stops in Prague that are within 500 meters from a tram stop.

nw, nr, wr, nwr

area["name:en"="Czechia"]->.a;(
nwr(area.a)["plant:source"=nuclear];
nwr(area.a)["landfill:waste"=nuclear];
nwr(area.a)["generator:source"=nuclear];
nwr(area.a)["hazard"=nuclear];
nwr(area.a)["disused:generator:source"=nuclear];
nwr(area.a)["military"="nuclear_explosion_site"];
);
(._;>>;);
out meta;
nwr["plant:source"=nuclear];
(
node["plant:source"=nuclear];
way["plant:source"=nuclear];
relation["plant:source"=nuclear];
);

How is all this useful?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store