Compare Sentinel-2 scale/offset evolution during time

Using SCL data from L2A

Import librairies

from matplotlib import pyplot as plt

from earthdaily import EarthDataStore, datasets

Load plot

# load geojson
pivot = datasets.load_pivot()

Init earthdatastore with environment variables or default credentials

eds = EarthDataStore()
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 <module>
    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.

Search for collection items

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

Get cube with rescale (*0.0001)

pivot_cube = get_cube(rescale=False) * 0.0001

Plots cube with SCL with at least 50% of clear data

pivot_cube.ed.plot_rgb(col_wrap=3)
plt.show()

Get cube with automatic rescale (default option)

pivot_cube = get_cube()
pivot_cube.clear_percent.plot.scatter(x="time")
plt.show()

Plots cube with SCL with at least 50% of clear data

pivot_cube.ed.plot_rgb(col_wrap=3)

plt.show()

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

Gallery generated by Sphinx-Gallery