Overpass turbo/Examples/Postal Codes Quality Assurance

From OpenStreetMap Wiki
Jump to navigation Jump to search
Overpass API logo.svg
edit
Overpass API · Language reference · Language guide · Technical terms · Areas · Query examples · Sparse Editing · Permanent ID · FAQ · more · Web site
Servers status · Versions · Development · Technical design · Installation · XAPI compatibility layer · Public transport sketch lines · Applications · Source code and issues
Overpass turbo · Wizard · Overpass turbo shortcuts · MapCSS stylesheets · Export to GeoJSON · more · Development · Source code and issues · Web site
Overpass Ultra · Overpass Ultra extensions · MapLibre stylesheets ·more · Source code and issues · Web site

broom

Help (89606) - The Noun Project.svg


(This example, originally in German, originally deals with postal code boundary relations in Germany but can be used in other countries.)

Inspired by examples listed here (in German; equivalent English page here) The following comparisons can be visualized for OSM data:

Show all nodes and ways tagged with a certain postal code (addr:postcode=*) that are inside of a boundary relation tagged with the same postal code (postal_code=*)

The following query provides the possibly existing results by simply copying the code/s below and pasting it in the text section at the Overpass turbo website (http://overpass-turbo.eu):

/* Show all elements within a boundary relation with postal_code=x,
   which have the addr:postcode tag */

{{postcode=4000}} 
/* change the postal code here as you wish,
   but it must be a valid postal code of an existing boundary relation */

rel[postal_code="{{postcode}}"];(._;>;);out;
/* this line is only for visualization of the hopefully existing boundary relation,
   comment out or delete only if necessary */

area[postal_code="{{postcode}}"]->.a;
(node(area.a)["addr:postcode"]["addr:postcode"!="{{postcode}}"];
 way(area.a)["addr:postcode"]["addr:postcode"!="{{postcode}}"];)
;(._;>;);out;
/* ... Click Run (or Ctrl-Enter), and if necessary,
   let the map zoom in on the hopefully appearing data
   by clicking on the magnifying glass icon */

Here is a more extended example from User:Basstoelpel:

/* Show all elements within a boundary relation with postal_code=x,
   which have the addr:postcode tag */
{{postcode=4031}} 
/* change the postal code here as you wish,
   but it must be a valid postal code of an existing boundary relation */
rel[postal_code="{{postcode}}"];
out;
>;
out skel;
/* this line is only for visualization of the hopefully existing boundary relation,
   comment out or delete only if necessary */
area[postal_code="{{postcode}}"]->.a;
(node(area.a)["addr:postcode"]["addr:postcode"!="{{postcode}}"];
way(area.a)["addr:postcode"]["addr:postcode"!="{{postcode}}"];
rel(area.a)["addr:postcode"]["addr:postcode"!="{{postcode}}"];
way(area.a)["postal_code"]["postal_code"!="{{postcode}}"];    
node(area.a)["postal_code"];        
way(area.a)["postal_code"]["building"];
rel(area.a)["postal_code"];);
out;
>;
out skel;
/* ... Click Run (or Ctrl-Enter), and if necessary,
   let the map zoom in on the hopefully appearing data
   by clicking on the magnifying glass icon */
                            
/* Relations should also be checked since buildings with courtyards are mapped using multipolygon relations.
Please ignore roads with a tagged postal code if they overlap with a postal code that you're querying. 
Everything else with the postal_code tag can be ignored too.
*/

Notes and Tips

  • If errors are displayed, then you should carefully check if individual addr:* objects have the wrong postal code or that the border of the postal code relation is incorrect.
  • A map that shows postal code relations and boundary relations with postal code tags can be found here. Mouse over to Theme Maps, click on "Administrative boundaries" and select the "Postal Codes" layer