.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/field_evolution.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_field_evolution.py: Field evolution and zonal stats ================================================================= Using Agriculture cloud mask from EarthDaily, and data from L2A, zonal stats for evolution .. GENERATED FROM PYTHON SOURCE LINES 8-10 Import librairies ------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: Python from matplotlib import pyplot as plt import earthdaily as ed .. GENERATED FROM PYTHON SOURCE LINES 16-18 Load plot ------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 18-22 .. code-block:: Python # load geojson pivot = ed.datasets.load_pivot() .. GENERATED FROM PYTHON SOURCE LINES 23-25 Init earthdatastore with environment variables or default credentials ---------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: Python eds = ed.EarthDataStore() .. GENERATED FROM PYTHON SOURCE LINES 29-31 Search for collection items for June 2022. where at least 50% of the field is clear according to the native cloudmask. .. GENERATED FROM PYTHON SOURCE LINES 31-42 .. code-block:: Python datacube = eds.datacube( "sentinel-2-l2a", intersects=pivot, datetime=["2022-06", "2022-07"], assets=["red", "green", "blue", "nir"], mask_with="native", clear_cover=50, ) datacube.clear_percent.plot.scatter(x="time") .. image-sg:: /_auto_examples/images/sphx_glr_field_evolution_001.png :alt: spatial_ref = 0 :srcset: /_auto_examples/images/sphx_glr_field_evolution_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 43-45 Add spectral indices using spyndex from earthdaily accessor ------------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: Python datacube = datacube.ed.add_indices(["NDVI"]) .. GENERATED FROM PYTHON SOURCE LINES 49-51 Plots cube with SCL with at least 50% of clear data ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 51-56 .. code-block:: Python datacube = datacube.load() datacube.ed.plot_rgb(col_wrap=4, vmin=0, vmax=0.3) plt.title("Pivot evolution masked with native cloudmasks") plt.show() .. image-sg:: /_auto_examples/images/sphx_glr_field_evolution_002.png :alt: time = 2022-06-03, time = 2022-06-11, time = 2022-06-16, time = 2022-06-18, time = 2022-06-23, time = 2022-06-26, time = 2022-06-28, time = 2022-07-13, time = 2022-07-18, time = 2022-07-21, time = 2022-07-23, Pivot evolution masked with native cloudmasks :srcset: /_auto_examples/images/sphx_glr_field_evolution_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 57-59 Compute zonal stats for the pivot ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 59-65 .. code-block:: Python zonal_stats = datacube.ed.zonal_stats(pivot, ["mean", "max", "min"]) zonal_stats.isel(feature=0).to_array(dim="band").plot.line( x="time", col="band", hue="zonal_statistics", col_wrap=3 ) plt.show() .. image-sg:: /_auto_examples/images/sphx_glr_field_evolution_003.png :alt: band = red, band = green, band = blue, band = nir, band = NDVI :srcset: /_auto_examples/images/sphx_glr_field_evolution_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 33.372 seconds) .. _sphx_glr_download__auto_examples_field_evolution.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: field_evolution.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: field_evolution.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: field_evolution.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_