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

Open the product#

First, open a Landsat-8 OLI-TIRS collection 2 product.

path = os.path.join("/home", "data", "DATA", "PRODS", "LANDSATS_COL2", "LC08_L1TP_200030_20201220_20210310_02_T1.tar")
reader = Reader()
prod = reader.open(path)
prod
eoreader.LandsatProduct 'LC08_L1TP_200030_20201220_20210310_02_T1'
Attributes:
	condensed_name: 20201220T104856_L8_200030_OLI_TIRS
	path: /home/data/DATA/PRODS/LANDSATS_COL2/LC08_L1TP_200030_20201220_20210310_02_T1.tar
	constellation: Landsat-8
	sensor type: Optical
	product type: L1
	default pixel size: 30.0
	default resolution: 30.0
	acquisition datetime: 2020-12-20T10:48:56
	band mapping:
		COASTAL_AEROSOL: 1
		BLUE: 2
		GREEN: 3
		RED: 4
		NIR: 5
		NARROW_NIR: 5
		CIRRUS: 9
		SWIR_1: 6
		SWIR_2: 7
		THERMAL_IR_1: 10
		THERMAL_IR_2: 11
		PANCHROMATIC: 8
	needs extraction: False
	cloud cover: 16.36
	tile name: 200030

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")
<matplotlib.collections.QuadMesh at 0x7fbf20314c10>
../_images/d370804f1339150303c6322b233fe9373be0864a76d9cb52ef514c39b1e4046b.png
bands[CLOUDS].plot()
<matplotlib.collections.QuadMesh at 0x7fbf202ce620>
../_images/1e47ad39c023e6de76f42591827a77cb336c364ac4dcc259c03a0068836efc01.png

Remove clouds from TIR band#

cloud_free = bands[TIR_1].where(bands[CLOUDS] == 0)
cloud_free.plot(cmap="viridis")
<matplotlib.collections.QuadMesh at 0x7fbf200bac80>
../_images/bce945435280d2431aa846266a575302413c1b121ed2617f547d5c16f5d90604.png