<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Airport terminal layouts &mdash; Cartes 0.8.4 documentation</title>
      <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
      <link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=e59714d7" />
      <link rel="stylesheet" type="text/css" href="../_static/jupyter-sphinx.css" />
      <link rel="stylesheet" type="text/css" href="../_static/thebelab.css" />
      <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira Sans|Ubuntu:regular,bold&subset=Latin&display=swap" />
      <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Noto Sans JP:thin,regular,bold&display=swap" />
      <link rel="stylesheet" type="text/css" href="../_static/main_stylesheet.css?v=ee88ba8d" />

  
      <script src="../_static/jquery.js?v=5d32c60e"></script>
      <script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
      <script src="../_static/documentation_options.js?v=b41f4c93"></script>
      <script src="../_static/doctools.js?v=9bcbadda"></script>
      <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
      <script src="../_static/thebelab-helper.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
      <script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
      <script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
      <script src="https://unpkg.com/@jupyter-widgets/html-manager/dist/embed-amd.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@^1.0.1/dist/embed-amd.js"></script>
    <script src="../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Peaks in Mercantour National Park" href="mercantour.html" />
    <link rel="prev" title="Airport layouts" href="airports.html" /> 
</head>

<body class="wy-body-for-nav">
<!-- force the fonts to be put in cache in advance -->
<div id="ubuntu">Ubuntu <b>bold</b></div>
<div id="fontin">Fontin Sans <b>bold</b></div>
<div id="notojp">東京都</div>

  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../index.html" class="icon icon-home">
            Cartes
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../projections.html">CRS and projections</a></li>
<li class="toctree-l1"><a class="reference internal" href="../atlas.html">Atlas</a></li>
<li class="toctree-l1"><a class="reference internal" href="../osm.html">OpenStreetMap</a></li>
<li class="toctree-l1"><a class="reference internal" href="../visualisation.html">Data visualisation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../gallery.html">Example gallery</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="../gallery.html#basic-examples">Basic examples</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="capitals.html">European (major) capitals</a></li>
<li class="toctree-l3"><a class="reference internal" href="footprint.html">Building footprints in a given city</a></li>
<li class="toctree-l3"><a class="reference internal" href="airports.html">Airport layouts</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Airport terminal layouts</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#data-acquisition">Data acquisition</a></li>
<li class="toctree-l4"><a class="reference internal" href="#data-preprocessing">Data preprocessing</a></li>
<li class="toctree-l4"><a class="reference internal" href="#data-visualisation">Data visualisation</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="mercantour.html">Peaks in Mercantour National Park</a></li>
<li class="toctree-l3"><a class="reference internal" href="switzerland.html">Swiss cantons</a></li>
<li class="toctree-l3"><a class="reference internal" href="hongkong.html">Build a map with tiles from various providers</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../gallery.html#advanced-examples">Advanced examples</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../troubleshooting.html">Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../alternatives.html">Alternative libraries</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">Cartes</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../gallery.html">Example gallery</a></li>
      <li class="breadcrumb-item active">Airport terminal layouts</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../_sources/gallery/terminal.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="airport-terminal-layouts">
<h1>Airport terminal layouts<a class="headerlink" href="#airport-terminal-layouts" title="Link to this heading"></a></h1>
<a class="reference internal image-reference" href="../_images/eham_gates.png"><img alt="Amsterdam airport" class="align-center" src="../_images/eham_gates.png" style="width: 510.59999999999997px; height: 462.0px;" />
</a>
<section id="data-acquisition">
<h2>Data acquisition<a class="headerlink" href="#data-acquisition" title="Link to this heading"></a></h2>
<p>Download nodes, ways and relations with the <code class="docutils literal notranslate"><span class="pre">aeroway</span></code> tag within area marked with IATA code <code class="docutils literal notranslate"><span class="pre">AMS</span></code> (Amsterdam airport). The ICAO code (here <code class="docutils literal notranslate"><span class="pre">EHAM</span></code>) may also be used.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">cartes.osm</span><span class="w"> </span><span class="kn">import</span> <span class="n">Overpass</span>

<span class="n">airport</span> <span class="o">=</span> <span class="n">Overpass</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="n">area</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">iata</span><span class="o">=</span><span class="s2">&quot;AMS&quot;</span><span class="p">),</span> <span class="n">aeroway</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="data-preprocessing">
<h2>Data preprocessing<a class="headerlink" href="#data-preprocessing" title="Link to this heading"></a></h2>
<p>None</p>
</section>
<section id="data-visualisation">
<h2>Data visualisation<a class="headerlink" href="#data-visualisation" title="Link to this heading"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">matplotlib.offsetbox</span><span class="w"> </span><span class="kn">import</span> <span class="n">AnchoredText</span>

<span class="kn">from</span><span class="w"> </span><span class="nn">cartes.crs</span><span class="w"> </span><span class="kn">import</span> <span class="n">Amersfoort</span><span class="p">,</span> <span class="n">PlateCarree</span>

<span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span>
    <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span> <span class="mi">15</span><span class="p">),</span>
    <span class="n">subplot_kw</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">projection</span><span class="o">=</span><span class="n">Amersfoort</span><span class="p">())</span>
<span class="p">)</span>

<span class="n">airport</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">by</span><span class="o">=</span><span class="s2">&quot;aeroway&quot;</span><span class="p">,</span>
    <span class="n">gate</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s2">&quot;C0&quot;</span><span class="p">),</span>  <span class="c1"># change default color for gates to C0 blue</span>
    <span class="n">tower</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">markersize</span><span class="o">=</span><span class="mi">3000</span><span class="p">)</span>  <span class="c1"># enlarge default size</span>
<span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">spines</span><span class="p">[</span><span class="s2">&quot;geo&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">set_visible</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>

<span class="c1"># Focus on the terminal area (gates), with a little buffer (in terms of lat/lon degrees)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">set_extent</span><span class="p">(</span><span class="n">airport</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s1">&#39;aeroway==&quot;gate&quot;&#39;</span><span class="p">),</span> <span class="n">buffer</span><span class="o">=</span><span class="mf">1e-3</span><span class="p">)</span>


<span class="c1"># This is about some semi-automatic placement of text labels</span>

<span class="k">def</span><span class="w"> </span><span class="nf">horizontal</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">name</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="s2">&quot;BCMH&quot;</span><span class="p">:</span>
        <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">name</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">&amp;</span> <span class="mi">1</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="k">return</span> <span class="s2">&quot;right&quot;</span>
    <span class="k">if</span> <span class="n">name</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="s2">&quot;EFG&quot;</span><span class="p">:</span>
        <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">name</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">&amp;</span> <span class="mi">1</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="k">return</span> <span class="s2">&quot;right&quot;</span>
    <span class="k">return</span> <span class="s2">&quot;left&quot;</span>


<span class="k">def</span><span class="w"> </span><span class="nf">vertical</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">name</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="s2">&quot; D&quot;</span><span class="p">:</span>
        <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">name</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">&amp;</span> <span class="mi">1</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="k">return</span> <span class="s2">&quot;bottom&quot;</span>
    <span class="k">if</span> <span class="n">name</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="s2">&quot;MH&quot;</span><span class="p">:</span>
        <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">name</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">&amp;</span> <span class="mi">1</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="k">return</span> <span class="s2">&quot;bottom&quot;</span>
    <span class="k">return</span> <span class="s2">&quot;top&quot;</span>


<span class="n">style</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
    <span class="n">transform</span><span class="o">=</span><span class="n">PlateCarree</span><span class="p">(),</span>
    <span class="n">color</span><span class="o">=</span><span class="s2">&quot;white&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">16</span><span class="p">,</span>
    <span class="n">fontweight</span><span class="o">=</span><span class="s2">&quot;bold&quot;</span><span class="p">,</span> <span class="n">font</span><span class="o">=</span><span class="s2">&quot;Frutiger&quot;</span><span class="p">,</span>  <span class="c1"># what else?</span>
    <span class="n">bbox</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">facecolor</span><span class="o">=</span><span class="s2">&quot;C0&quot;</span><span class="p">,</span> <span class="n">edgecolor</span><span class="o">=</span><span class="s2">&quot;none&quot;</span><span class="p">,</span> <span class="n">boxstyle</span><span class="o">=</span><span class="s2">&quot;round&quot;</span><span class="p">),</span>
<span class="p">)</span>

<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">airport</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s1">&#39;aeroway == &quot;gate&quot;&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">iterrows</span><span class="p">():</span>
    <span class="k">if</span> <span class="n">elt</span><span class="o">.</span><span class="n">ref</span> <span class="o">==</span> <span class="n">elt</span><span class="o">.</span><span class="n">ref</span><span class="p">:</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span>
            <span class="n">elt</span><span class="o">.</span><span class="n">longitude</span><span class="p">,</span> <span class="n">elt</span><span class="o">.</span><span class="n">latitude</span><span class="p">,</span> <span class="n">elt</span><span class="o">.</span><span class="n">ref</span><span class="o">.</span><span class="n">center</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span>
            <span class="n">ha</span><span class="o">=</span><span class="n">horizontal</span><span class="p">(</span><span class="n">elt</span><span class="o">.</span><span class="n">ref</span><span class="p">),</span> <span class="n">va</span><span class="o">=</span><span class="n">vertical</span><span class="p">(</span><span class="n">elt</span><span class="o">.</span><span class="n">ref</span><span class="p">),</span>
            <span class="n">rotation</span><span class="o">=</span><span class="mi">45</span> <span class="k">if</span> <span class="n">elt</span><span class="o">.</span><span class="n">ref</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;D&quot;</span> <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="o">**</span><span class="n">style</span>
        <span class="p">)</span>

<span class="c1"># Title of the map</span>

<span class="n">text</span> <span class="o">=</span> <span class="n">AnchoredText</span><span class="p">(</span>
    <span class="s2">&quot;Amsterdam Schiphol airport&quot;</span><span class="p">,</span>
    <span class="n">loc</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span>
    <span class="n">prop</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;size&quot;</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span> <span class="s2">&quot;fontname&quot;</span><span class="p">:</span> <span class="s2">&quot;Fira Sans&quot;</span><span class="p">,</span> <span class="p">},</span>
    <span class="n">frameon</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">text</span><span class="o">.</span><span class="n">patch</span><span class="o">.</span><span class="n">set_boxstyle</span><span class="p">(</span><span class="s2">&quot;round,pad=0.,rounding_size=0.2&quot;</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">add_artist</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="airports.html" class="btn btn-neutral float-left" title="Airport layouts" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="mercantour.html" class="btn btn-neutral float-right" title="Peaks in Mercantour National Park" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2021, Xavier Olive.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>  

<!-- Google tag (gtag.js) -->
<script async
    src="https://www.googletagmanager.com/gtag/js?id=G-S76SFPX8CV"></script>
    <script>
          window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());

            gtag('config', 'G-S76SFPX8CV');
    </script>

<!-- Remove hard-coded borders on pandas dataframes -->
<script>
  const elements = document.getElementsByClassName("dataframe");
  for (let i = 0; i < elements.length; i++) {
    const elt = elements[i];
    elt.setAttribute("border", 0);
  }
</script>



</body>
</html>