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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_gallery_caribbean-bathymetry.py>`
        to download the full example code

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

.. _sphx_glr_gallery_caribbean-bathymetry.py:


Bathymetry single-beam surveys of the Caribbean
-----------------------------------------------

This dataset is a compilation of several public domain single-beam bathymetry
surveys of the ocean in the Caribbean. The data display a wide range of
tectonic activity and uneven distribution.

**Original source:** `NOAA NCEI
<https://ngdc.noaa.gov/mgg/geodas/trackline.html>`__

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

.. admonition:: Changes in version 2
    :class: note

    In version 1, there were 1,938,095 data taking up a larger area. The
    data were ``depth_m`` and positive downward. Version 2, cropped the
    data to make it more manageable and converted the depths to bathymetric
    heights (negative downward).

.. GENERATED FROM PYTHON SOURCE LINES 31-37

.. code-block:: Python


    import pandas as pd
    import pygmt

    import ensaio








.. GENERATED FROM PYTHON SOURCE LINES 38-39

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

.. GENERATED FROM PYTHON SOURCE LINES 39-42

.. code-block:: Python

    fname = ensaio.fetch_caribbean_bathymetry(version=2)
    print(fname)





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

 .. code-block:: none

    /home/runner/work/_temp/cache/ensaio/v2/caribbean-bathymetry.csv.xz




.. GENERATED FROM PYTHON SOURCE LINES 43-44

Load the CSV formatted data with pandas

.. GENERATED FROM PYTHON SOURCE LINES 44-47

.. 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>survey_id</th>
          <th>latitude</th>
          <th>longitude</th>
          <th>bathymetry_m</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th>0</th>
          <td>86005311</td>
          <td>16.09652</td>
          <td>-61.52117</td>
          <td>-187</td>
        </tr>
        <tr>
          <th>1</th>
          <td>86005311</td>
          <td>16.09415</td>
          <td>-61.52104</td>
          <td>-177</td>
        </tr>
        <tr>
          <th>2</th>
          <td>86005311</td>
          <td>16.09177</td>
          <td>-61.52091</td>
          <td>-185</td>
        </tr>
        <tr>
          <th>3</th>
          <td>86005311</td>
          <td>16.08940</td>
          <td>-61.52078</td>
          <td>-188</td>
        </tr>
        <tr>
          <th>4</th>
          <td>86005311</td>
          <td>16.08703</td>
          <td>-61.52066</td>
          <td>-192</td>
        </tr>
        <tr>
          <th>...</th>
          <td>...</td>
          <td>...</td>
          <td>...</td>
          <td>...</td>
        </tr>
        <tr>
          <th>294316</th>
          <td>JR336</td>
          <td>15.28529</td>
          <td>-57.01258</td>
          <td>-5276</td>
        </tr>
        <tr>
          <th>294317</th>
          <td>JR336</td>
          <td>15.28705</td>
          <td>-57.00994</td>
          <td>-5277</td>
        </tr>
        <tr>
          <th>294318</th>
          <td>JR336</td>
          <td>15.28883</td>
          <td>-57.00732</td>
          <td>-5278</td>
        </tr>
        <tr>
          <th>294319</th>
          <td>JR336</td>
          <td>15.29057</td>
          <td>-57.00467</td>
          <td>-5277</td>
        </tr>
        <tr>
          <th>294320</th>
          <td>JR336</td>
          <td>15.29234</td>
          <td>-57.00203</td>
          <td>-5276</td>
        </tr>
      </tbody>
    </table>
    <p>294321 rows × 4 columns</p>
    </div>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 48-49

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

.. GENERATED FROM PYTHON SOURCE LINES 49-66

.. code-block:: Python

    fig = pygmt.Figure()
    pygmt.makecpt(
        cmap="cmocean/topo+h",
        series=[data.bathymetry_m.min(), data.bathymetry_m.max()],
    )
    fig.plot(
        x=data.longitude,
        y=data.latitude,
        fill=data.bathymetry_m,
        cmap=True,
        style="c0.02c",
        projection="M15c",
        frame=True,
    )
    fig.colorbar(frame='af+l"bathymetry [m]"')
    fig.coast(land="#666666")
    fig.show()



.. image-sg:: /gallery/images/sphx_glr_caribbean-bathymetry_001.png
   :alt: caribbean bathymetry
   :srcset: /gallery/images/sphx_glr_caribbean-bathymetry_001.png
   :class: sphx-glr-single-img






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

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


.. _sphx_glr_download_gallery_caribbean-bathymetry.py:

.. only:: html

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

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

      :download:`Download Jupyter notebook: caribbean-bathymetry.ipynb <caribbean-bathymetry.ipynb>`

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

      :download:`Download Python source code: caribbean-bathymetry.py <caribbean-bathymetry.py>`


.. only:: html

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

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