Overpass API/Areas

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Overpass API/Areas
· Afrikaans · Alemannisch · aragonés · asturianu · azərbaycanca · Bahasa Indonesia · Bahasa Melayu · Bân-lâm-gú · Basa Jawa · Baso Minangkabau · bosanski · brezhoneg · català · čeština · dansk · Deutsch · eesti · English · español · Esperanto · estremeñu · euskara · français · Frysk · Gaeilge · Gàidhlig · galego · Hausa · hrvatski · Igbo · interlingua · Interlingue · isiXhosa · isiZulu · íslenska · italiano · Kiswahili · Kreyòl ayisyen · kréyòl gwadloupéyen · Kurdî · latviešu · Lëtzebuergesch · lietuvių · magyar · Malagasy · Malti · Nederlands · Nedersaksies · norsk bokmål · norsk nynorsk · occitan · Oromoo · oʻzbekcha/ўзбекча · Plattdüütsch · polski · português · português do Brasil · română · shqip · slovenčina · slovenščina · Soomaaliga · suomi · svenska · Tiếng Việt · Türkçe · Vahcuengh · vèneto · Wolof · Yorùbá · Zazaki · српски / srpski · беларуская · български · қазақша · македонски · монгол · русский · тоҷикӣ · українська · Ελληνικά · Հայերեն · ქართული · नेपाली · मराठी · हिन्दी · অসমীয়া · বাংলা · ਪੰਜਾਬੀ · ગુજરાતી · ଓଡ଼ିଆ · தமிழ் · తెలుగు · ಕನ್ನಡ · മലയാളം · සිංහල · ไทย · မြန်မာဘာသာ · ລາວ · ភាសាខ្មែរ · ⵜⴰⵎⴰⵣⵉⵖⵜ · አማርኛ · 한국어 · 日本語 · 中文(简体)‎ · 吴语 · 粵語 · 中文(繁體)‎ · ייִדיש · עברית · اردو · العربية · پښتو · سنڌي · فارسی · ދިވެހިބަސް
Overpass turbo · Overpass API · Language reference · Query examples · Language Guide · Advanced examples · Sparse Editing · FAQ · MapCSS · more: Overpass turbo · Overpass API

Areas are an extension of Overpass API: They constitute a new data type area beside the OSM data types node, way, and relation. So this data is not extracted and updated from the main API, but computed by a special process on the Overpass API server.

Areas can be used in queries according to the language guide and language reference.

We explain here in more detail the computation process: The computation process is executed in an infinite loop on the Overpass API server, where each run lasts between 4 and 12 hours. It used to execute the following script, which is nowadays replaced by a more sophisticated version (see link above):

Note: this script is meant to be exclusively run on the server. Any other Overpass API user (like overpass turbo) can neither trigger the area creation nor directly influence the area creation rules. If you think the area creation rules are incomplete, you should raise a Github issue.


<?xml version="1.0" encoding="UTF-8"?>
<osm-script timeout="86400" element-limit="1073741824">

<union>
  <query type="relation">
    <has-kv k="admin_level"/>
    <has-kv k="name"/>
  </query>
  <query type="relation">
    <has-kv k="type" v="multipolygon"/>
    <has-kv k="name"/>
  </query>
  <query type="relation">
    <has-kv k="postal_code"/>
  </query>
  <query type="relation">
    <has-kv k="addr:postcode"/>
  </query>
</union>
<foreach into="pivot">
  <union>
    <recurse type="relation-way" from="pivot"/>
    <recurse type="way-node"/>
  </union>
  <make-area pivot="pivot"/>
</foreach>

<query type="way">
  <has-kv k="area" v="yes"/>
  <has-kv k="name"/>
</query>
<foreach into="pivot">
  <union>
    <item set="pivot"/>
    <recurse type="way-node" from="pivot"/>
  </union>
  <make-area pivot="pivot"/>
</foreach>

</osm-script>

Let's walk through the file: We derive one area from each relation that

  • have a tag admin_level and a tag name,
  • have a tag type with value multipolygon and a tag name,
  • have a tag postal_code, or
  • have a tag addr:postcode.

This is subject of the first union block.

In the following foreach block, the area is actually created: the shape is built from the way members of the relation, the tags are copied from the relation itself, the pivot object.

The second union block selects all ways that have a tag area with value yes and a tag name. Here, we create one area for each way. The tags are taken here from the respective way, as well as the shape.