
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/british-columbia-lidar.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_british-columbia-lidar.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_british-columbia-lidar.py:


Topography of the Trail Islands in British Columbia, Canada
-----------------------------------------------------------

This is a lidar point cloud (ground reflections only) sliced to the small
`Trail Islands <https://apps.gov.bc.ca/pub/bcgnws/names/21973.html>`__
to the North of Vancouver. The islands have some nice looking topography and
their isolated nature creates problems for some interpolation methods.

**Original source:** `LidarBC
<https://www2.gov.bc.ca/gov/content/data/geographic-data-services/lidarbc>`__

**Pre-processing:** `Source code for preparation of the original dataset for
redistribution in Ensaio
<https://github.com/fatiando-data/british-columbia-lidar>`__

.. GENERATED FROM PYTHON SOURCE LINES 24-30

.. code-block:: Python


    import pandas as pd
    import pygmt

    import ensaio








.. GENERATED FROM PYTHON SOURCE LINES 31-32

Download and cache the data and return the path to it on disk

.. GENERATED FROM PYTHON SOURCE LINES 32-35

.. code-block:: Python

    fname = ensaio.fetch_british_columbia_lidar(version=1)
    print(fname)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    /home/runner/work/_temp/cache/ensaio/v1/british-columbia-lidar.csv.xz




.. GENERATED FROM PYTHON SOURCE LINES 36-37

Load the CSV formatted data with pandas

.. GENERATED FROM PYTHON SOURCE LINES 37-40

.. code-block:: Python

    data = pd.read_csv(fname)
    data






.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <div>
    <style scoped>
        .dataframe tbody tr th:only-of-type {
            vertical-align: middle;
        }

        .dataframe tbody tr th {
            vertical-align: top;
        }

        .dataframe thead th {
            text-align: right;
        }
    </style>
    <table border="1" class="dataframe">
      <thead>
        <tr style="text-align: right;">
          <th></th>
          <th>longitude</th>
          <th>latitude</th>
          <th>elevation_m</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th>0</th>
          <td>-123.813753</td>
          <td>49.460263</td>
          <td>-0.67</td>
        </tr>
        <tr>
          <th>1</th>
          <td>-123.813725</td>
          <td>49.460274</td>
          <td>-0.96</td>
        </tr>
        <tr>
          <th>2</th>
          <td>-123.813764</td>
          <td>49.460254</td>
          <td>-0.78</td>
        </tr>
        <tr>
          <th>3</th>
          <td>-123.813744</td>
          <td>49.460262</td>
          <td>-0.61</td>
        </tr>
        <tr>
          <th>4</th>
          <td>-123.813737</td>
          <td>49.460265</td>
          <td>-0.62</td>
        </tr>
        <tr>
          <th>...</th>
          <td>...</td>
          <td>...</td>
          <td>...</td>
        </tr>
        <tr>
          <th>829728</th>
          <td>-123.807407</td>
          <td>49.455007</td>
          <td>-1.24</td>
        </tr>
        <tr>
          <th>829729</th>
          <td>-123.807410</td>
          <td>49.454995</td>
          <td>-1.25</td>
        </tr>
        <tr>
          <th>829730</th>
          <td>-123.807416</td>
          <td>49.454980</td>
          <td>-1.19</td>
        </tr>
        <tr>
          <th>829731</th>
          <td>-123.807428</td>
          <td>49.454966</td>
          <td>-1.21</td>
        </tr>
        <tr>
          <th>829732</th>
          <td>-123.807432</td>
          <td>49.454963</td>
          <td>-1.20</td>
        </tr>
      </tbody>
    </table>
    <p>829733 rows × 3 columns</p>
    </div>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 41-42

Make a PyGMT map with the data points colored by the elevation.

.. GENERATED FROM PYTHON SOURCE LINES 42-59

.. code-block:: Python

    fig = pygmt.Figure()
    fig.basemap(
        region=[
            data.longitude.min(),
            data.longitude.max(),
            data.latitude.min(),
            data.latitude.max(),
        ],
        projection="M15c",
        frame=True,
    )
    pygmt.makecpt(cmap="viridis", series=[data.elevation_m.min(), data.elevation_m.max()])
    fig.plot(
        x=data.longitude, y=data.latitude, fill=data.elevation_m, cmap=True, style="c0.05c"
    )
    fig.colorbar(frame='af+l"elevation [m]"')
    fig.show()



.. image-sg:: /gallery/images/sphx_glr_british-columbia-lidar_001.png
   :alt: british columbia lidar
   :srcset: /gallery/images/sphx_glr_british-columbia-lidar_001.png
   :class: sphx-glr-single-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 12.613 seconds)


.. _sphx_glr_download_gallery_british-columbia-lidar.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: british-columbia-lidar.ipynb <british-columbia-lidar.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: british-columbia-lidar.py <british-columbia-lidar.py>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
