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

.. only:: html

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

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

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

.. _sphx_glr_io_examples_open_save_read_satimg.py:


Parsing sensor metadata
=======================

This example demonstrates the instantiation of a raster while parsing image sensor metadata.

.. GENERATED FROM PYTHON SOURCE LINES 7-10

.. code-block:: Python


    import geoutils as gu








.. GENERATED FROM PYTHON SOURCE LINES 11-12

We print the filename of our raster that, as often with satellite data, holds metadata information.

.. GENERATED FROM PYTHON SOURCE LINES 12-17

.. code-block:: Python

    filename_geoimg = gu.examples.get_path("everest_landsat_b4")
    import os

    print(os.path.basename(filename_geoimg))





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

 .. code-block:: none

    LE71400412000304SGS00_B4.tif




.. GENERATED FROM PYTHON SOURCE LINES 18-19

We open it as a raster with the option to parse metadata, un-silencing the attribute retrieval to see it printed.

.. GENERATED FROM PYTHON SOURCE LINES 19-21

.. code-block:: Python

    img = gu.Raster(filename_geoimg, parse_sensor_metadata=True, silent=False)





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

 .. code-block:: none

    Setting platform as Landsat 7 read from filename.
    Setting sensor as ETM+ read from filename.
    Setting tile_name as 140041 read from filename.
    Setting datetime as 2000-10-30 00:00:00 read from filename.




.. GENERATED FROM PYTHON SOURCE LINES 22-23

We have now retrieved the metadata, stored in the :attr:`geoutils.Raster.tags` attribute.

.. GENERATED FROM PYTHON SOURCE LINES 23-24

.. code-block:: Python

    img.tags




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

 .. code-block:: none


    {'AREA_OR_POINT': 'Point', 'COMPRESSION': 'LZW', 'INTERLEAVE': 'BAND', 'platform': 'Landsat 7', 'sensor': 'ETM+', 'product': None, 'version': None, 'tile_name': '140041', 'datetime': datetime.datetime(2000, 10, 30, 0, 0)}




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

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


.. _sphx_glr_download_io_examples_open_save_read_satimg.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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