Removing clouds#
Let’s use EOReader with optical data, in order to remove clouds from brightness temperature measurements
Imports#
import os
from eoreader.reader import Reader
from eoreader.bands import TIR_1, CLOUDS
/home/docs/checkouts/readthedocs.org/user_builds/eoreader/envs/stable/lib/python3.9/site-packages/dask/dataframe/__init__.py:42: FutureWarning:
Dask dataframe query planning is disabled because dask-expr is not installed.
You can install it with `pip install dask[dataframe]` or `conda install dask`.
This will raise in a future version.
warnings.warn(msg, FutureWarning)
Open the product#
First, open a Landsat-8 OLI-TIRS
collection 2 product.
path = os.path.join("/home", "prods", "LANDSATS_COL2", "LC08_L1TP_200030_20201220_20210310_02_T1.tar")
reader = Reader()
prod = reader.open(path)
prod
There is no existing products in EOReader corresponding to /home/prods/LANDSATS_COL2/LC08_L1TP_200030_20201220_20210310_02_T1.tar.
Load clouds and TIR band#
# Load those bands as a dict of xarray.DataArray
bands = prod.load([TIR_1, CLOUDS])
bands[TIR_1].plot(cmap="viridis")
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 2
1 # Load those bands as a dict of xarray.DataArray
----> 2 bands = prod.load([TIR_1, CLOUDS])
3 bands[TIR_1].plot(cmap="viridis")
AttributeError: 'NoneType' object has no attribute 'load'
bands[CLOUDS].plot()
<matplotlib.collections.QuadMesh at 0x7f2ec00fb7f0>
Remove clouds from TIR band#
cloud_free = bands[TIR_1].where(bands[CLOUDS] == 0)
cloud_free.plot(cmap="viridis")