User:M!dgard/Overpass queries

From OpenStreetMap Wiki
Jump to navigation Jump to search

Use the steering wheel icon to the right of the code to load it in Overpass turbo at https://overpass-turbo.eu/.

Map of ways where geometry was changed by a certain user

Caution: in regions where the mapper was very active, run this on limited bboxes only or you'll get a very high amount of data back!

try it yourself in overpass-turbo
[out:json][timeout:25];

/*
 * Note: this does not find ways that have been
 * completely changed later (e.g. just moved
 * entirely), and also selects ways that are
 * drawn or modified to use a mapper's
 * pre-existing nodes, even though they didn't
 * choose to modify those ways.
 */

// Select nodes last modified by user
node(user:"M!dgard")({{bbox}});

// Select parent ways for nodes in the input set
// See https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Recurse_.28n.2C_w.2C_r.2C_bn.2C_bw.2C_br.29
way(bn);

out body; >; out skel qt;

Map of post code areas

You can build a basic map of post codes in Belgium with this query. Postal code areas are complete in Flanders and Brussels.

try it yourself in overpass-turbo
[timeout:60];
area["name:en"=Belgium]->.boundaryarea;

relation[boundary=postal_code](area.boundaryarea);
out body;
>;
out skel qt;

{{style:
  relation         { text: postal_code; fill-color: #A8EA8D; fill-opacity: 0.05; color: #000; width: 1; opacity: 1; }
  relation:active  { color: #50BD23; fill-opacity: 0;   width: 3; }
  relation:tainted { color: #F00;    fill-opacity: 0.5; fill-color: #F00; }
}}

Map of pipelines in Belgium

Make sure to dim the background tiles for better visibility (Settings → Map → Tiles Opacity: 0.6) and check Settings → Map → “Don't display small features as POI” before running the query.

try it yourself in overpass-turbo
[out:json][timeout:120];

area["name:en"=Belgium]->.searchArea;
way[man_made=pipeline](area.searchArea);
out body; >; out skel qt;

{{style:
way { color: #555; opacity: 0.8; width: 2; }
way[type], way[substance=natural_gas]
 /* incorrect tags: pink */ { color: #ff00bd; }
way[substance=water]        { color: #005eff; }
way[substance=gas]          { color: #ff5800; }
way[substance=hydrogen]     { color: #8a00cf; }
way[substance=oxygen]       { color: #00cec6; }
way[substance=nitrogen]     { color: #ff0800; }
way[substance=kerosene]     { color: #04de6b; }
way[substance=fuel]         { color: #277005; }
way[substance=hydrocarbons] { color: #c1de04; }
way[substance=beer]         { color: #7d4f0d; }
way:active { opacity: 1; width: 3; }
}}

Significant electrical substations in Belgium

try it yourself in overpass-turbo
[out:json][timeout:60];
area["name:en"=Belgium]->.searchArea;
nwr["power"="substation"]["voltage"~"^([0-9]{6,}|[2-9][0-9]{4})($|;)"](area.searchArea);
out body; >; out skel qt;

Map of vicinal roads in Belgium

With an emphasis on those that are possibly illegally made private (bright red) or have disappeared (dotted).

try it yourself in overpass-turbo
/* Make sure to enable “Don't display small features as POIs.”
 * in the Overpass Turbo settings before running.
 *
 * Greenish: paths (sentier, voetweg, voetpad, pad)
 * Reddish: roads (chemin, weg, rijweg, baan)
 *
 * Full lines: existing roads
 * Dotted lines: no longer existing roads
 *
 * Bright red: access prohibited
 */

[out:json][timeout:25];
area["name:en"=Belgium]->.searchArea;
way["vicinal_type"](area.searchArea);
out body; >; out skel qt;

{{style:
way { width: 2; opacity: 0.9; }
way[vicinal_type=path] { color: #140; }
way[vicinal_type=road] { color: #944; }
way[vicinal_type=path][access=private],
way[vicinal_type=road][access=private] { color: #d00; width: 5; }
way[!highway] { dashes: 1,10; width: 5; }
way:active { width: 5; opacity: 1; }
}}

Map of public bicycle parkings in bbox

Can use some better design, but useful all the same.

try it yourself in overpass-turbo
[out:json][timeout:25];
nwr["amenity"="bicycle_parking"][access=yes]({{bbox}});
out body; >; out skel qt;

{{style:
node[amenity=bicycle_parking], area[amenity=bicycle_parking] {
  icon-image: url('icons/osmic/parking-bicycle-18.png');
  icon-width: 18;
}
}}

Which streets have name:etymology:wikidata=*

try it yourself in overpass-turbo
[out:json][timeout:25];

/* Choose your area of interest here. */
/* Choose 8 (municipality) or 9 (section) */
area["name:en"=Brussels][admin_level=9]->.sa;

way[highway][name](area.sa);
out body; >; out skel;

{{style:
way {
  color: orange;
}
way[name:etymology:wikidata] {
  color: blue;
}
}}

Street names in a municipality

try it yourself in overpass-turbo
[out:csv(name)][timeout:25];

/* Choose your area of interest here. */
/* Choose 8 (municipality) or 9 (section) */
area["name:en"=Brussels][admin_level=9]->.sa;

(
  way[highway][name](area.sa);
  -
  way[highway=service](area.sa);
);
out body; >; out skel;

QA: wrong tagging

These export to XML, ready to load in JOSM.

Stuff tagged with tel=* instead of phone=*

try it yourself in overpass-turbo
[out:xml][timeout:10];
nwr["tel"~"[0-9]{2}"];
out meta qt; >; out meta qt;

Stuff with illegal format for phone=*

try it yourself in overpass-turbo
[out:xml][timeout:120];
nwr[phone][phone!~"^\\+[0-9]{1,3} [0-9 -]+(;\\+[0-9]{1,3} [0-9 -]+)*$"]({{bbox}});
out meta qt; >; out meta qt;

phone=* in Belgium with value that isn't a valid Belgian number

try it yourself in overpass-turbo
// This query finds all phone numbers in Belgium that are invalid or are incorrectly formatted.
// If they are invalid or not in the international format, they should be investigated and fixed.
// If they are valid, just changing them for the sake of it isn't really useful. Look around and verify data quality instead of focussing on just this one issue. Chances are this isn't the only problem you can solve!

// Formats:
// * By default geographical numbers look like +32 12 34 56 78
// * In some cities, numbers look like         +32 9 876 54 32
// * Mobile phone numbers look like            +32 498 76 54 32
// * 070 and 078 numbers look like             +32 70 123 456
// * 0800 and 090x numbers look like           +32 800 12 345
// * 077 numbers exist but this query does not consider them valid, since they are for machine-to-machine communication.
// This query deals with all these cases.
// Source: https://en.wikipedia.org/w/index.php?title=Telephone_numbers_in_Belgium&oldid=865237188

// Last update: 2019-09-08 Don't match space-less phones by default

[out:xml][timeout:120];
area["name:en"="Belgium"]->.boundaryarea;

nwr[phone]["seamark:type"!=cable_submarine][phone!~"^\\+32 ?(([239] ?[0-9]{3}|4 ?[0-5][0-9]{2}|(4[5-9][0-9]|1[0-69]|5[0-9]|6[013-57-9]|71|8[0-79]) ?[0-9]{2}) ?[0-9]{2} ?[0-9]{2}|7[08] ?[0-9]{3} ?[0-9]{3}|(800|90[0-9]) ?[0-9]{2} ?[0-9]{3})(; *\\+32 ?(([239] ?[0-9]{3}|4 ?[0-5][0-9]{2}|(4[5-9][0-9]|1[0-69]|5[0-9]|6[013-57-9]|71|8[0-79]) ?[0-9]{2}) ?[0-9]{2} ?[0-9]{2}|7[08] ?[0-9]{3} ?[0-9]{3}|(800|90[0-9]) ?[0-9]{2} ?[0-9]{3}))*$"](area.boundaryarea);

// Stricter variant: also match numbers without spaces that are otherwise valid, like +3270123456
// nwr[phone]["seamark:type"!=cable_submarine][phone!~"^\\+32 (([239] [0-9]{3}|4 [0-5][0-9]{2}|(4[5-9][0-9]|1[0-69]|5[0-9]|6[013-57-9]|71|8[0-79]) [0-9]{2}) [0-9]{2} [0-9]{2}|7[08] [0-9]{3} [0-9]{3}|(800|90[0-9]) [0-9]{2} [0-9]{3})(; *\\+32 (([239] [0-9]{3}|4 [0-5][0-9]{2}|(4[5-9][0-9]|1[0-69]|5[0-9]|6[013-57-9]|71|8[0-79]) [0-9]{2}) [0-9]{2} [0-9]{2}|7[08] [0-9]{3} [0-9]{3}|(800|90[0-9]) [0-9]{2} [0-9]{3}))*$"](area.boundaryarea);

out meta qt; >; out meta qt;

Stuff with missing protocol in website=* or url=*

try it yourself in overpass-turbo
[out:xml][timeout:120];
(
  nwr[website][website!~"^https?://"]({{bbox}});
  nwr[url][url!~"^[a-z]+://"]({{bbox}});
);
out meta qt; >; out meta qt;

Stuff incorrectly mapped with postal_code=* in Flanders

Anything that isn't a postal code boundary is not allowed to have the tag postal_code=*. Postal code boundaries in Flanders are complete, so it's safe to remove postal_code=* from other objects (after checking that they match with the value of the postal code area they're in).

try it yourself in overpass-turbo
[out:xml][timeout:120];
area["name"="Vlaanderen"]->.boundaryarea;
(
  nwr["postal_code"](area.boundaryarea);
  - relation["boundary"="postal_code"];
);
out meta qt;
>;
out meta qt;

Old-style pipeline tagging in Belgium

try it yourself in overpass-turbo
[out:xml][timeout:120];

area["name:en"=Belgium]->.searchArea;
way[man_made=pipeline][type](area.searchArea);
out body; >; out skel qt;

DO NOT just change the tag. This is a great opportunity to follow the pipelines on the aerial imagery and improve the trajectory where possible.

Names with quotation marks

try it yourself in overpass-turbo
[out:xml][timeout:25];
nwr["name"~"'.*'|[\"“”‘’]"]({{bbox}});
out body; >; out skel qt;

Misuse of designation=*

try it yourself in overpass-turbo
[out:xml][timeout:25];
nwr[designation][designation!~"^(vicinal_road|towpath|communal_road_ss|right_of_way_ss|communal_road)$"]({{bbox}});
out body; >; out skel qt;

Substations with voltage in name and not in voltage

try it yourself in overpass-turbo
[out:xml][timeout:60];
/* Without [power=substation] *all* objects with voltages in the name are found, but that can only be done on small areas */
nwr[power=substation][!voltage][name~"[0-9] *[kK][vV]"]({{bbox}});
out body; >; out skel qt;

Substations with voltage in name

try it yourself in overpass-turbo
[out:xml][timeout:60];
nwr[name~"[kK][vV]$"]({{bbox}});
out body; >; out skel qt;

Substations that likely have a typo in voltage

try it yourself in overpass-turbo
[out:xml][timeout:600];
area["name:en"=Belgium]->.searchArea;
/* Find voltages that are not normally used in Belgium, but the results of division by some multiple of 10 are. */
/* So these likely have one or more zeroes in excess. */
nwr[voltage~"(^|;)(10|11|12|30|36|72|150|220|380)[0-9]000+($|;)"](area.searchArea);
out body; >; out skel qt;

Variant: find all uncommon voltages

Feel free to adapt to your country and put the query here in a new section.

Belgium
try it yourself in overpass-turbo
[out:xml][timeout:600];
area["name:en"=Belgium]->.searchArea;
nwr[voltage][voltage!=0][!railway][voltage!~"^(23[01]|380|400|11400|(1|3|10|11|12|15|30|33|36|50|70|150|220|380|400)000)(;(23[01]|380|400|11400|(1|3|10|11|12|15|30|33|36|50|70|150|220|380|400)000))*$"](area.searchArea);
out body; >; out skel qt;

Candidates for substation=minor_distribution

try it yourself in overpass-turbo
[out:xml][timeout:300];
(
  (
    nwr[power=substation][voltage~"(^|;)1[0-9]{4}($|;)"]({{bbox}});
    - nwr[substation]({{bbox}});
  );
  - nwr[voltage~"(^|;)([3-9][0-9]{4}|[1-9][0-9]{5,})($|;)"]({{bbox}});
);
out body; >; out skel qt;

Comma as decimal separator

try it yourself in overpass-turbo
[out:xml][timeout:120];
nwr[~"^max([wh]eight|length)(:forward|:backward)?$"~","]({{bbox}});
out meta qt; >; out meta qt;

Mapillary key with a URL instead of just the key

try it yourself in overpass-turbo
[out:xml][timeout:60];
// From a URL like
//   https://www.mapillary.com/app/?lat=51.100&lng=2.581&z=17&pKey=iLKfAt78NwwDEsvDwjAseA&focus=photo
// you should only take the "pKey", part so here iLKfAt78NwwDEsvDwjAseA.
// Likewise from
//   http://www.mapillary.com/map/im/ygke9-akAun5q_v3PNRWPg/photo
// only ygke9-akAun5q_v3PNRWPg.
nwr["mapillary"~"^https?://"]({{bbox}});
out meta qt; >; out meta qt;

Minor_distribution substations with possibly too high voltage

try it yourself in overpass-turbo
[out:xml][timeout:120];
(
  nwr[power=substation][substation=minor_distribution]["voltage"~"(^|;)([0-9]{6}|[3-9][0-9]{4})"]({{bbox}});
  nwr[power=substation][operator=Fluvius]["voltage"~"(^|;)([0-9]{6}|[3-9][0-9]{4})"]({{bbox}});
  nwr[power=substation][operator=Eandis]["voltage"~"(^|;)([0-9]{6}|[3-9][0-9]{4})"]({{bbox}});
);
out meta qt; >; out meta qt;