
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "generated/gallery/scalar_data/from_tiff__rgb.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_scalar_data_from_tiff__rgb.py>`
        to download the full example code.

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

.. _sphx_glr_generated_gallery_scalar_data_from_tiff__rgb.py:


GeoTIFF RGB
-----------

This example demonstrates how to render an
`OGC GeoTIFF <https://www.ogc.org/standard/geotiff/>`_ RGB image as a
geolocated mesh.

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

Creates a mesh from a GeoTIFF encoded RGB image.

The resulting mesh contains quad cells.

The GeoTIFF RGB image is first pre-processed using :func:`rasterio.features.sieve`
to remove several unwanted masked regions within the interior of the image, which
are due to a lack of dynamic range in the ``uint8`` image data.

Note that, the RGB image pixel data is located on the mesh nodes/points.

The masked RGB pixels are then removed by extracting only mesh cells with no
masked points.

.. tags:: GeoTIFF, Lighting, RGB

.. attention:: Optional package dependency :mod:`rasterio` is required.

----

.. GENERATED FROM PYTHON SOURCE LINES 38-79







.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /generated/gallery/scalar_data/images/sphx_glr_from_tiff__rgb_001.png
        :alt: from tiff  rgb
        :srcset: /generated/gallery/scalar_data/images/sphx_glr_from_tiff__rgb_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/scalar_data/images/sphx_glr_from_tiff__rgb_001.vtksz






.. code-block:: Python


    from __future__ import annotations

    import geovista as gv
    from geovista.pantry import fetch_raster
    import geovista.theme


    def main() -> None:
        """Plot a GeoTIFF RGB image.

        Notes
        -----
        .. versionadded:: 0.5.0

        """
        # Fetch the example GeoTIFF file.
        fname = fetch_raster("bahamas_rgb.tif")

        # Plot the RGB image.
        plotter = gv.GeoPlotter()

        # Load the GeoTIFF image, which requires the optional package
        # dependency 'rasterio'.
        mesh = gv.Transform.from_tiff(fname, rgb=True, sieve=True, extract=True)

        plotter.add_mesh(mesh, lighting=False, rgb=True)
        plotter.add_axes()
        plotter.add_text(
            "Bahamas, RGB GeoTIFF",
            position="upper_left",
            font_size=10,
            shadow=True,
        )
        plotter.view_xz()
        plotter.camera.zoom(1.3)
        plotter.show()


    if __name__ == "__main__":
        main()


.. _sphx_glr_download_generated_gallery_scalar_data_from_tiff__rgb.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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