.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/compare_scale_s2.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_compare_scale_s2.py: Compare Sentinel-2 scale/offset evolution during time ================================================================= Using SCL data from L2A .. 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 from earthdaily import EarthDataStore, datasets .. GENERATED FROM PYTHON SOURCE LINES 16-18 Load plot ------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 18-22 .. code-block:: Python # load geojson pivot = datasets.load_pivot() .. GENERATED FROM PYTHON SOURCE LINES 23-25 Init earthdatastore with environment variables or default credentials ---------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 25-29 .. code-block:: Python eds = EarthDataStore() .. rst-class:: sphx-glr-script-out .. code-block:: pytb Traceback (most recent call last): File "/private/var/folders/_t/czv_cfrd613_6_gd_p8qpqd80000gp/T/tmpmap_d3kq/7261d0bf6bc6b22a0278281791f6623d19ddf89a/examples/compare_scale_s2.py", line 26, in eds = EarthDataStore() ^^^^^^^^^^^^^^^^ File "/private/var/folders/_t/czv_cfrd613_6_gd_p8qpqd80000gp/T/tmpmap_d3kq/7261d0bf6bc6b22a0278281791f6623d19ddf89a/earthdaily/__init__.py", line 51, in EarthDataStore return earthdatastore.Auth.from_credentials( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/_t/czv_cfrd613_6_gd_p8qpqd80000gp/T/tmpmap_d3kq/7261d0bf6bc6b22a0278281791f6623d19ddf89a/earthdaily/earthdatastore/__init__.py", line 464, in from_credentials config = cls.read_credentials( ^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/_t/czv_cfrd613_6_gd_p8qpqd80000gp/T/tmpmap_d3kq/7261d0bf6bc6b22a0278281791f6623d19ddf89a/earthdaily/earthdatastore/__init__.py", line 529, in read_credentials raise NotImplementedError("Credentials weren't found.") NotImplementedError: Credentials weren't found. .. GENERATED FROM PYTHON SOURCE LINES 30-32 Search for collection items .. GENERATED FROM PYTHON SOURCE LINES 32-45 .. code-block:: Python def get_cube(rescale=True): pivot_cube = eds.datacube( "sentinel-2-l2a", intersects=pivot, datetime=["2022-01-01", "2022-03-10"], assets=["red", "green", "blue"], mask_with="native", # same as scl clear_cover=50, # at least 50% of the polygon must be clear rescale=rescale, ) return pivot_cube .. GENERATED FROM PYTHON SOURCE LINES 46-48 Get cube with rescale (*0.0001) ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: Python pivot_cube = get_cube(rescale=False) * 0.0001 .. GENERATED FROM PYTHON SOURCE LINES 52-54 Plots cube with SCL with at least 50% of clear data ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 54-58 .. code-block:: Python pivot_cube.ed.plot_rgb(col_wrap=3) plt.show() .. GENERATED FROM PYTHON SOURCE LINES 59-61 Get cube with automatic rescale (default option) ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 61-66 .. code-block:: Python pivot_cube = get_cube() pivot_cube.clear_percent.plot.scatter(x="time") plt.show() .. GENERATED FROM PYTHON SOURCE LINES 67-69 Plots cube with SCL with at least 50% of clear data ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 69-73 .. code-block:: Python pivot_cube.ed.plot_rgb(col_wrap=3) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.222 seconds) .. _sphx_glr_download__auto_examples_compare_scale_s2.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: compare_scale_s2.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: compare_scale_s2.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: compare_scale_s2.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_