User:M!dgard/Overpass queries

From OpenStreetMap Wiki
Jump to: navigation, 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")(([http://openstreetmap.org/?minlon={{{minlon}}}&minlat={{{minlat}}}&maxlon={{{maxlon}}}&maxlat={{{maxlat}}} bbox={{{minlon}}},{{{minlat}}},{{{maxlon}}},{{{maxlat}}}]));

// 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; }
}}

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];
(
  node["tel"~"[0-9]{2}"];
  way["tel"~"[0-9]{2}"];
  relation["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];
(
  node[phone][phone!~"^\\+[0-9]{1,3} [0-9 -]+(;\\+[0-9]{1,3} [0-9 -]+)*$"]({{bbox}});
  way[phone][phone!~"^\\+[0-9]{1,3} [0-9 -]+(;\\+[0-9]{1,3} [0-9 -]+)*$"]({{bbox}});
  relation[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 not formatted in the preferred way.
// 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.

// 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-01-06 Recognize 080-089 area codes

[out:xml][timeout:120];
area["name:en"="Belgium"]->.boundaryarea;
(
  node[phone][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);
  way[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);
  relation[phone][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];
(
  node[website][website!~"^https?://"]({{bbox}});
  way[website][website!~"^https?://"]({{bbox}});
  relation[website][website!~"^https?://"]({{bbox}});
  node[url][url!~"^[a-z]+://"]({{bbox}});
  way[url][url!~"^[a-z]+://"]({{bbox}});
  relation[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;
(
  (
    node["postal_code"](area.boundaryarea);
    way["postal_code"](area.boundaryarea);
    relation["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:json][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.