User:Binnette/OverpassQueries
Tools
Objects mapped as node, that 'can' be mapped as area
Get all camp_site mapped as nodes, they can be mapped as areas. Challenge: Convert camp site nodes to areas in France

area[name="France"]->.a;
node["tourism"="camp_site"](area.a);
out skel;
Shops without proper brand tags
Get all 'Burger King' fast-food that don't have the proper brand tags. Challenge: Add brand tags for Burger King - World

area[name="France métropolitaine"]->.a;
(
node[name~"Burger King",i][!"brand:wikidata"](area.a);
way[name~"Burger King",i][!"brand:wikidata"](area.a);
)->.all;
nw.all[!highway][!bus][!place][!power][!information][amenity!=parking];
out body geom;
| # | Challenge | Query |
|---|---|---|
| 1 | Add proper tags for Quick (fast food) - World | |
| 2 | Add brand tags for Subway - World | |
| 3 | Add proper tags to KFC - World | |
| 4 | Add proper tags to McDonald's - World | |
| 5 | Ajout de tags brand sur les supermarchés en France | |
| 6 | Add missing tags to "Big Fernand" fast-food - France | area[name="France"]->.a;
(
nw[name="Big Fernand"][!"brand"](area.a);
nw[name="Big Fernand"][!"brand:wikidata"](area.a);
nw[name="Big Fernand"]["brand:wikidata"!="Q19521346"](area.a);
nw[name="Big Fernand"][!"brand:wikipedia"](area.a);
nw[name="Big Fernand"][!"cuisine"](area.a);
nw[name="Big Fernand"][!"takeaway"](area.a);
nw[name="Big Fernand"]["takeaway"!="yes"](area.a);
nw[name="Big Fernand"][!"amenity"](area.a);
nw[name="Big Fernand"]["amenity"!="fast_food"](area.a);
nw[name="Big Fernand"][!"website"](area.a);
);
out ids geom;
|
| 7 | Add missing tags to "Buffalo Grill" (restaurant) - World | area[name="France"]->.a;
(
nw[name="Buffalo Grill"][!amenity](area.a);
nw[name="Buffalo Grill"][amenity!=restaurant](area.a);
nw[name="Buffalo Grill"][!brand](area.a);
nw[name="Buffalo Grill"][brand!="Buffalo Grill"](area.a);
nw[name="Buffalo Grill"][!"brand:wikidata"](area.a);
nw[name="Buffalo Grill"]["brand:wikidata"!="Q944655"](area.a);
nw[name="Buffalo Grill"][!"brand:wikipedia"](area.a);
nw[name="Buffalo Grill"][!"cuisine"](area.a);
nw[name="Buffalo Grill"]["cuisine"!="steak_house"](area.a);
);
out body geom;
|
Missing tag: direction
Get all stops that don't have the direction tag and are not located on a one-way road. Challenge: Add direction to Stop in France

area[name="France"]->.a;
node["highway"="stop"][!"direction"](area.a);
way(bn)["highway"]["oneway"!="yes"];
node(w)["highway"="stop"][!"direction"];
out skel;
| # | Challenge | Query |
|---|---|---|
| 1 | Add direction to give way in France
Get give_way that don't have the direction tag and are not located on a one-way road. |
|
| 2 | Add direction to traffic signals - France | area["ISO3166-2"="FR-ARA"]->.ARA; // Auvergne-Rhône-Alpes
node(area.ARA)
[traffic_signals=signal]
[!"traffic_signals:direction"]->.sign;
way[highway][oneway=yes](bn.sign);
node(w)
[traffic_signals=signal]
[!"traffic_signals:direction"]->.signOneWay;
(.sign; - .signOneWay;);
out meta;
|
Query on angles with the functions per_vertex and angle
Challenge: Impossible angles - France
area[name="Isère"]->.a;
way(area.a)
[highway~"motorway|trunk|primary|secondary|tertiary|unclassified|residential|service"]
(if:lrs_in(1,per_vertex(angle() < -170 || angle() > 170)));
node(w)(if:lrs_in(id(),set(per_vertex((angle() < -170 || angle() > 170) ? ref() : 0))));
out geom;
Run query: http://overpass-turbo.eu/s/1B2h
MapRoulette challenges
France
| Num | Link | Overpass query |
|---|---|---|
| 4 | Update buildings with fixme from cadastre in France
Get ways with a fixme that contains the word 'cadastre'. Filter to keep only the ways not modified since the date (2016-01-01). Finally filter the ways to keep only the buildings. |
|
| 10 | Replace shop=yes by more specific shop value in France |
area[name="France métropolitaine"]->.a;
(
node["shop"="yes"][name](area.a);
way["shop"="yes"][name](area.a);
);
out body geom;
Find shop with name="Easy Cash" and shop!=yes: |
| 14 | Fix "roads" on building - France (38)
Ok, so this query is very long... May be it is not very 'optimized' but it works. ^^' |
area[name="Isère"]->.a;
// roads
way(area.a)[highway]
[highway!=pedestrian]
[highway!=footway]
[highway!=platform]
[highway!=steps]
[highway!=path]
[highway!=bus_stop]
[highway!=living_street]
[!layer]
[!tunnel];
(._;>;)->.nhighways;
// tunnels & way with layer
(
way(area.a)[highway][tunnel];
way(area.a)[highway][layer];
);
(._;>;)->.ntunnels;
// buildings ways
way(area.a)[building]
[!"building:levels"]
[building!=roof]
[wall!=no]
[!layer];
(._;>;);
// building nodes but not entrance
node._[amenity!=parking_entrance]
[!entrance]->.nbuildings;
// node that are from building & roads
// except tunnels node
(
node.nhighways.nbuildings;
-
node.ntunnels;
);
out ids geom;
|
| 14b | Fix "roads" on building - France (38)
Version 2. I used map_to_area to convert buildings to areas |
area[name="Isère"]->.a;
// buildings
way(area.a)[building]
[!"building:levels"]
[building!=roof]
[wall!=no]
[!layer];
// area covered by building
map_to_area -> .areabuilding;
// roads
way(area.areabuilding)[!layer][!tunnel][highway] -> .highways;
(
way.highways[highway=living_street];
way.highways[highway=motorway];
way.highways[highway=motorway_junction];
way.highways[highway=motorway_link];
way.highways[highway=path];
way.highways[highway=primary];
way.highways[highway=primary_link];
way.highways[highway=residential];
way.highways[highway=road];
way.highways[highway=secondary];
way.highways[highway=secondary_link];
way.highways[highway=service];
way.highways[highway=services];
way.highways[highway=tertiary];
way.highways[highway=tertiary_link];
way.highways[highway=track];
way.highways[highway=trunk];
way.highways[highway=trunk_link];
way.highways[highway=unclassified];
);
out body geom;
|
| 16 | Add missing giveways to roundabout - France (38) |
area[name="Grenoble"]->.a;
way[junction=roundabout](area.a)->.round;
node[highway=give_way](around.round:10);
way[junction=roundabout](around:10);
complete {
node(w);
way[junction=roundabout](bn);
}
(._;)->.roundWithGive;
(.round; - .roundWithGive;)->.roundNoGive;
foreach.roundNoGive->.c {
way.c.visited;
if (count(ways) == 0){
.c;
complete {
node(w);
way[junction=roundabout](bn);
}
(._;)->.new;
way.new.ok;
if (count(ways) == 0){
(.c;.ok;)->.ok;
}
(.new; .visited;)->.visited;
}
}
way.ok;
out geom;
//debug only
//node[highway=give_way](area.a);
//out geom;
{{style:
way[junction=roundabout]{
fill-color: red;
color: red;
}
node[highway=give_way]{
fill-color: green;
color: green;
}
}}
|
| 17 | Fuel stations too far from road - France (38) | |
| 18 | Extract give way from roundabout - France | |
| 21 | Fix ways without tag - France (38) | |
| 22 | Add footways in cemetery - France (38) | |
| 25 | Fire station too close to another one - France |
area["ISO3166-2"="FR-ARA"]->.ARA; // Auvergne-Rhône-Alpes
()->.ko;
(
nw[amenity=fire_station](area.ARA);
//nw[amenity=fire_station](area.BFC);
//...
)->.allstations;
foreach.allstations->.s {
nw[amenity=fire_station](around.s:50);
if (count(nw) > 1) {
(.s;.ko;)->.ko;
}
}
nw.ko;
out geom;
|
| 26 | Fire station too close to another one | |
| 27 | Fix areas without tag - France | |
| 29 | Police station too close to another one - France |
Same as previous fire station challenge. But this time I used QGIS to filter data returned by Overpass API. |
| 30 | Townhall too close to another one - France |
Same as previous fire station challenge. But this time I used QGIS to filter data returned by Overpass API. |
| 31 | Stop should be on a highway - France | |
| 32 | Add missing give ways around mini roundabout - France | |
| 34 | Add incline to stairs in France | |
| 35 | Add elevation (tag ele) for natural=peak | |
| 36 | The website of this shop is down. Update website or remove the shop if closed |
I. Find shops with website and export to csv: [out:csv(::id,::type,name,shop,website;false;";")];
area["ISO3166-2"="FR-ARA"]->.ARA; // Auvergne-Rhône-Alpes
(
node["shop"]["website"](area.ARA);
way["shop"]["website"](area.ARA);
);
out body;
II. Test website with bash/curl: #!/bin/bash
INPUT=shop.csv
OLDIFS=$IFS
IFS=';'
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
echo "id;type;statut;name;shop;website" > res.csv
while read id type name shop website
do
response=$(curl --write-out '%{http_code}' --silent --output /dev/null $website)
firstChar=${response:0:1}
if [ $firstChar != 2 ] && [ $firstChar != 3 ]
then
echo "❌ $response => $website"
echo "$id;$type;ko;$name;$shop;$website" >> res.csv
else
echo "✅ $response => $website"
fi
done < $INPUT
IFS=$OLDIFS
III. Create a MapRoulette challenge with the query (replace the shop ids): |
| 37 | Add the artwork_type of this artwork - France |
area[name="France"]->.a;
(
node["tourism"="artwork"][!"artwork_type"]["description"](area.a);
node["tourism"="artwork"][!"artwork_type"]["mapillary"](area.a);
node["tourism"="artwork"][!"artwork_type"]["name"](area.a);
node["tourism"="artwork"][!"artwork_type"]["wikimedia_commons"](area.a);
//node["tourism"="artwork"][!"artwork_type"]["artwork_subject"](area.a);
//node["tourism"="artwork"][!"artwork_type"]["website"](area.a);
//node["tourism"="artwork"][!"artwork_type"]["wikidata"](area.a);
//node["tourism"="artwork"][!"artwork_type"]["wikipedia"](area.a);
);
out body geom;
|
| 38 | This "parking space" is too big. Should it be a parking lot instead? - France #QuickFix |
way
[amenity=parking_space]
[capacity=1]
[!parking_space]
(if:is_closed()==1)
(if:length()>100);
out geom;
Then open the data in JSOM and change all amenity=parking_space to amenity=parking. Save the changes in an osm file. Use this command on the file: mr cooperative tag parking.osm --out parking.geojson Finally, create a new MapRoulette challenge and upload the geojson file. |
| 39 | Wrong direction for stop on one way road in France | |
| 40 | Node amenity=school should probably be merged in the enclosing way amenity=school - Grenoble | |
| 41 | Add elevation (tag ele) for tourism=alpine_hut | |
| 42 | Waterfall should be on a river - France |
// Get area of "France métropolitaine"
area[name="France métropolitaine"]->.FRM;
// Get waterfalls within `.FRM`
node[waterway=waterfall](area.FRM)->.waterfall;
// Get parent waterway of waterfall node (if any)
way[waterway](bn.waterfall);
// Get child waterfall nodes from those parents waterway
node[waterway=waterfall](w)->.withWaterway;
// Get parent water body of waterfall nodes (if any)
way[natural=water](bn.waterfall);
// Get child waterfall nodes from those parents water body
node[waterway=waterfall](w)->.withNaturalWater;
// Combine `.withWaterway` and `.withNaturalWater`
(.withWaterway; .withNaturalWater;) -> .withWater;
// Get waterfalls that are not part of waterway or water body
(.waterfall; - .withWater;);
out body;
|
World
| Num | Link | Overpass query |
|---|---|---|
| 12 | Guidepost elevation should be stored in the tag ele - World |
(
node[information=guidepost][name~"[0-9]+m$"][!ele][!running];
node[information=guidepost][name~"[0-9]+mt"][!ele][!running];
node[information=guidepost][name~"[0-9]+m)"][!ele][!running];
node[information=guidepost][name~"[0-9]+m."][!ele][!running];
node[information=guidepost][name~"[0-9]+m "][!ele][!running];
node[information=guidepost][height~'[0-9][0-9]+'][!ele];
);
out body geom;
|
Other users queries
| Num | Link | Overpass query |
|---|---|---|
| 1 | Add artwork_type=* to artworks based on images. | |
| 2 | Global: Improve:/Fix tag "access=public" | |
| 3 | Museums without a website in France |
MapRoulette QuickFix challenges
Peak elevation in name instead of ele tag
For node natural=peak, the elevation should be stored in ele=* not un name=*.
| Step | Action |
|---|---|
| 1) Get peaks with elevation in name | |
| 2) Compute data on JOSM via plugin "Scripting" | Install the plugin scripting in JOSM. Then import the peaks in a layer "peaks.osm".
And run the following script: var layer = josm.layers.get("peaks.osm");
var ds = layer.data;
var r = RegExp(/[0-9]+\s{0,1}m/);
ds.each(function(n) {
oldname = n.tags.name.replace("(","").replace(")","");
if (oldname.search(r) > 0) {
n.tags.name = oldname.replace(r, "").trim();
n.tags.ele = oldname.match(r).join().replace("m", "").trim();
}
});
josm.alert("End of script");
Then save the modification in an "peaks-changes.osm" file. |
| 3) Create and import the tasks in MapRoulette | Install the mr-cli node module command line.
Then run the following command: mr cooperative tag peaks-changes.osm --out peaks-quickfix.geojson Then import the geojson file in a new MapRoulette challenge |
Peak elevation in height instead of ele tag
| Step 1 | Step 2 | Step 3 |
|---|---|---|
var layer = josm.layers.get("peak-height.osm");
var ds = layer.data;
ds.each(function(n) {
var h = n.tags.height.replace("m","");
h = h.replace("(","").replace(")","");
n.tags.ele = h.trim();
n.tags.height = "";
});
josm.alert("End of script"); |
mr cooperative tag peaks-height.osm --out peaks-height-qf.geojson |
Extract peak elevation from wikidata
- Challenge: https://maproulette.org/browse/challenges/23281
- How to create this challenge: https://github.com/Binnette/mr-challenges/tree/main/peak-ele-wikidata
Filter Overpass queries by area
You can filter your query by area, here is an example for 'France métropolitaine:

area[name="France métropolitaine"]->.a;
node["tourism"="camp_site"](area.a);
out skel;
You can also use the function 'geocodeArea' to get your area :

[[:Template:GeocodeArea:France métropolitaine]]->.a;
node["tourism"="camp_site"](area.a);
out skel;
| # | Areas | Filters |
|---|---|---|
| 1 | Metropolitan France | area[name="France métropolitaine"]->.FRM;
area["ISO3166-2"="FR-ARA"]->.ARA; // Auvergne-Rhône-Alpes
area["ISO3166-2"="FR-BFC"]->.BFC; // Bourgogne-Franche-Comté
area["ISO3166-2"="FR-BRE"]->.BRE; // Bretagne
area["ISO3166-2"="FR-CVL"]->.CVL; // Centre-Val de Loire
area["ISO3166-2"="FR-COR"]->.COR; // Corse
area["ISO3166-2"="FR-GES"]->.GES; // Grand Est
area["ISO3166-2"="FR-HDF"]->.HDF; // Hauts-de-France
area["ISO3166-2"="FR-IDF"]->.IDF; // Île-de-France
area["ISO3166-2"="FR-NOR"]->.NOR; // Normandie
area["ISO3166-2"="FR-NAQ"]->.NAQ; // Nouvelle-Aquitaine
area["ISO3166-2"="FR-OCC"]->.OCC; // Occitanie
area["ISO3166-2"="FR-PDL"]->.PDL; // Pays de la Loire
area["ISO3166-2"="FR-PAC"]->.PAC; // Provence-Alpes-Côte d'Azur
// Regions grouped by location: North/South
(.BFC;.BRE;.CVL;.GES;.HDF;.IDF;.NOR;.PDL;)->.N; // Nord
(.ARA;.COR;.NAQ;.OCC;.PAC;)->.S; // Sud
// Regions grouped by location: NW/NE/SW/SE
(.BRE;.CVL;.IDF;.NOR;.PDL;)->.NO;
(.BFC;.GES;.HDF;)->.NE;
(.NAQ;.OCC;)->.SO;
(.ARA;.COR;.PAC;)->.SE;
rel(area.ARA)["name"="Ardèche"];
way(r);
out body;
>;
out skel qt;
|
| 2 | Overseas France | // DROM
area["ISO3166-2"="FR-GP"]->.GP; // Guadeloupe
area["ISO3166-2"="FR-GF"]->.GF; // Guyane (française)
area["ISO3166-2"="FR-MQ"]->.MQ; // Martinique
area["ISO3166-2"="FR-RE"]->.RE; // La Réunion
area["ISO3166-2"="FR-YT"]->.YT; // Mayotte
// Dependency
area["ISO3166-2"="FR-CP"]->.CP; // Île de Clipperton
// COM
area["ISO3166-2"="FR-BL"]->.BL; // Saint-Barthélemy
area["ISO3166-2"="FR-MF"]->.MF; // Saint-Martin
area["ISO3166-2"="FR-NC"]->.NC; // Nouvelle-Calédonie
area["ISO3166-2"="FR-PF"]->.PF; // Polynésie française
area["ISO3166-2"="FR-PM"]->.PM; // Saint-Pierre-et-Miquelon
area["ISO3166-2"="FR-TF"]->.TF; // Terres australes et antarctiques françaises
area["ISO3166-2"="FR-WF"]->.WF; // Wallis-et-Futuna
node(area.GP)[amenity=bench];
out;
|
| 3 | European countries | // West Europe
area["ISO3166-1"=AT]->.AT; //Austria
area["ISO3166-1"=BE]->.BE; //Belgium
area["ISO3166-1"=CZ]->.CZ; //Czech Republic
area["ISO3166-1"=DK]->.DK; //Denmark
area["ISO3166-1"=ES]->.ES; //Spain
area["ISO3166-1"=FR]->.FR; //France
area["ISO3166-1"=GB]->.GB; //United Kingdom
area["ISO3166-1"=HR]->.HR; //Croatia
area["ISO3166-1"=MT]->.MT; //Malta
area["ISO3166-1"=IE]->.IE; //Ireland
area["ISO3166-1"=IT]->.IT; //Italy
area["ISO3166-1"=LU]->.LU; //Luxembourg
area["ISO3166-1"=NL]->.NL; //Netherlands
area["ISO3166-1"=PT]->.PT; //Portugal
// East Europe
area["ISO3166-1"=BG]->.BG; //Bulgaria
area["ISO3166-1"=CY]->.CY; //Cyprus
area["ISO3166-1"=DE]->.DE; //Germany
area["ISO3166-1"=EE]->.EE; //Estonia
area["ISO3166-1"=FI]->.FI; //Finland
area["ISO3166-1"=GR]->.GR; //Greece
area["ISO3166-1"=HU]->.HU; //Hungary
area["ISO3166-1"=LT]->.LT; //Lithuania
area["ISO3166-1"=LV]->.LV; //Latvia
area["ISO3166-1"=PL]->.PL; //Poland
area["ISO3166-1"=RO]->.RO; //Romania
area["ISO3166-1"=SE]->.SE; //Sweden
area["ISO3166-1"=SI]->.SI; //Slovenia
area["ISO3166-1"=SK]->.SK; //Slovakia
|
| 4 | France county | Import des ornes de recharges pour véhicules électriques en Ardèche |
Performances

[out:json];
nw[name="KFC"]
// Arbitrary polygon containing Metropolitan France (without Corsica)
(poly:"42.1 3.0 42.9 -1.6 48.5 -5.0 51.3 2.2 49.0 8.25 43.2 7.8 42.1 3.0");
out body geom;
// Take 18 seconds

[out:json];
area[name="France métropolitaine"]->.a;
nw[name="KFC"](area.a);
out body geom;
// Take 24 seconds but contains also Corsica

// Just a simple box around Metropolitan France (with Corsica)
[out:json][bbox:41.32,-5.15,51.1,9.6];
nw[name="KFC"];
out body geom;
// Take 28 seconds

[out:json];
area["ISO3166-2"="FR-ARA"]->.ARA; // Auvergne-Rhône-Alpes
nw[name="KFC"](area.ARA);
out body geom;
// Take 40 seconds
Tips
| Description | Query |
|---|---|
| Search in multiple area.
You can join multiple places in a single area. |
|
| Search for a given value for any key | |
| Search for a given value for any key
^ starting or $ ending with specific char |
|
| Logical OR in values with a 'pipe' ∣
values église or école i for case insensitive |
|
| Convert a way or rel to an area | |
| Using 'pivot' to get the relation of an area | |
| I want a picnic table near drinking water and shelter |
Stats
| Description | Query |
|---|---|
| Tree count by species in Échirolles |
My OSM edits
| Description | Query |
|---|---|
| My edits in Grenoble | |
| My edits in Mariac |