Note
Go to the end to download the full example code.
Create a multisensor cube
With Sentinel-2 and Landsat, using Sentinel-2 spatial resolution.
Import librairies
from matplotlib import pyplot as plt
from earthdaily import EarthDataStore, datasets
Set parameters
Init earthdatastore with environment variables or default credentials
eds = EarthDataStore()
collections = ["sentinel-2-l2a", "landsat-c2l2-sr"]
datetime = ["2022-07-20", "2022-09-01"]
intersects = datasets.load_pivot_corumba()
assets = ["blue", "green", "red", "nir"]
mask_with = "native"
clear_cover = 50
resampling = "cubic"
cross_calibration_collection = "sentinel-2-l2a"
Traceback (most recent call last):
File "/private/var/folders/_t/czv_cfrd613_6_gd_p8qpqd80000gp/T/tmpmap_d3kq/7261d0bf6bc6b22a0278281791f6623d19ddf89a/examples/multisensors_cube.py", line 24, 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.
Create the multisensors datacube
datacube = eds.datacube(
collections,
assets=assets,
datetime=datetime,
intersects=intersects,
mask_with=mask_with,
clear_cover=clear_cover,
cross_calibration_collection=cross_calibration_collection,
)
# Add the NDVI
datacube = datacube.ed.add_indices(["NDVI"])
# Load in memory
datacube = datacube.load()
See the evolution in RGB
datacube.ed.plot_rgb(col_wrap=3)
plt.show()
See the NDVI evolution
datacube["NDVI"].ed.plot_band(col_wrap=3, vmin=0, vmax=0.8, cmap="Greens")
plt.show()
See the NDVI mean evolution
datacube["NDVI"].groupby("time").mean(...).plot.line(x="time")
plt.title("NDVI evolution")
plt.show()
Total running time of the script: (0 minutes 0.006 seconds)