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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_generated_gallery_unstructured_tri.py>`
        to download the full example code.

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

.. _sphx_glr_generated_gallery_unstructured_tri.py:


WW3 Triangular Mesh
-------------------

This example demonstrates how to render an unstructured triangular mesh.

📋 Summary
^^^^^^^^^^

Creates a mesh from 1-D latitude and longitude unstructured points and connectivity.

The resulting mesh contains triangular cells. The connectivity is required to
construct the cells by indexing into the unstructured points.

WAVEWATCH III (WW3) sea surface wave significant height data is located on
mesh nodes/points, which are then interpolated across the mesh faces/cells.

Finally, a Natural Earth base layer is rendered along with Natural Earth
coastlines.

.. tags:: Coastlines, Globe, Unstructured, Texture

----

.. GENERATED FROM PYTHON SOURCE LINES 32-76







.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /generated/gallery/unstructured/images/sphx_glr_tri_001.png
        :alt: tri
        :srcset: /generated/gallery/unstructured/images/sphx_glr_tri_001.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/geovista/checkouts/v0.5.3/docs/src/generated/gallery/unstructured/images/sphx_glr_tri_001.vtksz






.. code-block:: Python


    from __future__ import annotations

    import geovista as gv
    from geovista.pantry.data import ww3_global_tri
    import geovista.theme


    def main() -> None:
        """Plot a WW3 unstructured triangular mesh.

        Notes
        -----
        .. versionadded:: 0.1.0

        """
        # Load the sample data.
        sample = ww3_global_tri()

        # Create the mesh from the sample data.
        mesh = gv.Transform.from_unstructured(
            sample.lons, sample.lats, connectivity=sample.connectivity, data=sample.data
        )

        # Plot the unstructured mesh.
        plotter = gv.GeoPlotter()
        sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
        plotter.add_mesh(mesh, scalar_bar_args=sargs)
        plotter.add_base_layer(texture=gv.natural_earth_hypsometric())
        plotter.add_coastlines()
        plotter.add_axes()
        plotter.view_xy(negative=True)
        plotter.add_text(
            "WW3 Triangular Mesh (10m Coastlines)",
            position="upper_left",
            font_size=10,
            shadow=True,
        )
        plotter.camera.zoom(1.3)
        plotter.show()


    if __name__ == "__main__":
        main()


.. _sphx_glr_download_generated_gallery_unstructured_tri.py:

.. only:: html

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

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

      :download:`Download Jupyter notebook: tri.ipynb <tri.ipynb>`

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

      :download:`Download Python source code: tri.py <tri.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: tri.zip <tri.zip>`


.. only:: html

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

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