User:ZeLonewolf/Overpass cleanup queries

From OpenStreetMap Wiki
Jump to navigation Jump to search

Overpass Cleanup Queries

This page is a listing of queries used for identifying outdated, redundant, or useless tagging.

Queries for tagging that can be safely deleted

The queries below identify tagging that, in most cases, is redundant and can be safely deleted.

Boundaries & Protected Areas

Overpass Query What it finds
try it yourself in overpass-turbo
[timeout:360][out:json];
way["boundary"="protected_area"];
rel(bw)["boundary"="protected_area"];
way(r)["boundary"="protected_area"];
(._;>;);
out skel qt;
Ways tagged with boundary=protected_area but part of a relation that is also tagged with boundary=protected_area. A corner case is a properly tagged way that might be an enclave (tagged as a simple area) of a larger relation, in which both the enclave and the enclosing relation are different types of protected areas.

With the exception of that corner case, these ways can usually have the boundary=protected_area tag removed, as well as protect_class=* if present. As of 2020-11-03, 4784 ways, nearly all of which are in Europe.

try it yourself in overpass-turbo
[timeout:360][out:json];
way["protect_class"];
rel(bw)["boundary"="protected_area"];
way(r)["protect_class"];
(._;>;);
out skel qt;
Ways tagged with protect_class=* but part of a relation that is tagged with boundary=protected_area. A corner case is a properly tagged way that might be an enclave (tagged as a simple area) of a larger relation, in which both the enclave and the enclosing relation are different types of protected areas.

With the exception of that corner case, these ways can usually have the protect_class=* tag removed, as well as boundary=protected_area if present. As of 2020-11-16, 2076 ways, the vast majority of which are in Europe, mostly in the Czech Republic.

try it yourself in overpass-turbo
[timeout:360][out:json];
way["type"="boundary"];
(._;>;);
out skel qt;
Ways tagged with type=boundary. This tag is only used on relations, and can be safely removed from ways. As of 2020-11-21, 14464 ways, distributed worldwide, though virtually none are in the USA (except the Milwaukee area).
try it yourself in overpass-turbo
[timeout:360][out:json];
node["type"="boundary"];
(._;>;);
out skel qt;
Nodes tagged with type=boundary. This tag is only used on relations, and can be safely removed from nodes.

Symbol support vote.svg As of 2020-10-25, this query returns empty results.

try it yourself in overpass-turbo
[timeout:360][out:json];
relation["boundary"="aboriginal_lands"]["protect_class"="24"];
(._;>;);
out;
Relations tagged with boundary=aboriginal_lands and protect_class=24. These tags are redundant and both render identically. Thus, protect_class=24 can be safely deleted in these instances. As of 2020-11-21 there are 2692 ways and 381 relations, all in Brazil.
try it yourself in overpass-turbo
[timeout:360][out:json];
way["boundary"="administrative"]({{bbox}});
rel(bw)["boundary"="administrative"];
way(r)["boundary"="administrative"];
(._;>;);
out skel qt;
Administrative boundary relations tagged with member ways also tagged as boundaries. The tags on the member ways are redundant and don't change rendering. Thus, boundary=administrative can be safely deleted in these instances, unless the boundary is significant in its own right (e.g. "Mason-Dixon Line").

Queries for inconsistent tagging

The queries below identify tagging that is currently useless and should either be removed or fixed.

Overpass Query What it finds
try it yourself in overpass-turbo
[timeout:360][out:json];
way["protect_class"][!"boundary"];
(._;>;);
out skel qt;
Ways tagged with protect_class=* but no corresponding boundary=* tag. Either remove the protect_class=*, or add boundary=protected_area. As of 2020-11-21, 2475 ways; while these are lightly scattered about the planet, the majority of these are in Sweden and Poland.

Queries for non-rendering tagging

The queries below identify tagging that does not currently render but may be problematic in some way:

Overpass Query What it finds
try it yourself in overpass-turbo
[timeout:360][out:csv(::id,"name","place","natural","operator","wikipedia";true;"|")];
area["boundary"="protected_area"]["protect_class"!~"(1a|1b|1|2|3|4|5|6|24)"][!"leisure"][!"landuse"]["natural"!~"(wood|forest|sand|heath|scrub|wetland|bare_rock)"];
out;
Invisible protected areas

Closed ways tagged with boundary=protected_area but no corresponding tag that causes rendering. Duplicate (by name) entries in this CSV output may indicate sets of ways that should be collected into a boundary relation. As of 2020-10-25, 320 named entries which should be collected into a boundary relation.

Important Note: Area queries may lag reality by a day or two. Changes to the map are not immediately reflected in this query response.

try it yourself in overpass-turbo
[timeout:360][out:csv(::id,"name","place","natural","operator","wikipedia";true;"|")];
area["boundary"="protected_area"]["protect_class"!~"(1a|1b|1|2|3|4|5|6|24)"]["leisure"!~"nature_reserve"];
out;
Unbordered protected areas

Closed ways tagged with boundary=protected_area but no corresponding tag that causes border rendering. Duplicate (by name) entries in this CSV output may indicate sets of ways that should be collected into a boundary relation.

Unlike the query above, this query returns protected areas that do not currently have an outline border, regardless of whether or not it has a fill border, in the OSM Carto style. As of 2020-10-25, 407 named entries which should be collected into a boundary relation.

Important Note: Area queries may lag reality by a day or two. Changes to the map are not immediately reflected in this query response.

try it yourself in overpass-turbo
[timeout:360][out:json];
{{geocodeArea:"United States"}}->.a;
(
way["protect_class"]["protect_class"!~"^(1a|1b|1|2|3|4|5|6)$"](area.a);
rel["protect_class"]["protect_class"!~"^(1a|1b|1|2|3|4|5|6)$"](area.a); 
);
(._;>;);
out skel qt;
Areas tagged with non-standard protect_class=* values

Areas tagged with non-rendering protect_class=* values that don't correspond to IUCN protected area categories. If possible, these should be replaced with plain-English tagging.

Queries for outdated / deprecated tagging

The queries below identify outdated tagging schemes that can be safely replaced with newer tagging:

Overpass Query What it finds
try it yourself in overpass-turbo
[timeout:360][out:json];
nwr["protect_class"="24"];
(._;>;);
out;
Native, Indigenous, and Aboriginal Lands

All objects tagged with protect_class=24 can be safely replaced by boundary=aboriginal_lands, which is an approved replacement. As of 2020-11-21, 3162 ways and 415 relations, the vast majority in Brazil.

Overpass Needs-Fix Queries

Overpass Query What it finds
try it yourself in overpass-turbo
[timeout:60][out:xml];
rel["boundary"="administrative"]["admin_level"]({{bbox}});
(way(r:"");>;);
out skel qt;
Boundaries with a blank role

All relations tagged with boundary=protected_area require that members have non-blank roles. If there is a member with a missing role, this is an error that should be fixed. This is implemented as a bounding box query as the search space is large.

Highway Queries

Overpass Query What it finds
try it yourself in overpass-turbo
[out:json][timeout:2500];
{{geocodeArea:"Rhode Island"}}->.a;
(
  way[highway~"^(motorway|trunk|primary|secondary|tertiary)(_link)?$"](area.a);
  rel[type=route][route=road](area.a);
);
(._;>;);
out skel qt;
Roads and route relations in an area

Used for bulk highway re-classifications

try it yourself in overpass-turbo
[out:json][timeout:2500];
way[highway][name~"State Highway"]({{bbox}})->.highways;

.highways < ->.routed_highways;

rel(bw.highways) -> .parent_routes;
way(r.parent_routes) -> .routed_highways;

(
  .highways;
  - .routed_highways;
);

(._;>;);
out skel qt;
State Highways missing route relations

Used for finding missing highway relations

Useful Overpass Query Links