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 0x7f96247044d0>
../_images/0cd11f882c835732c3a4c0b969be15bbd2a37900fe9a527c0f640fe6ffc624ad.png
bands[CLOUDS].plot()
<matplotlib.collections.QuadMesh at 0x7f962479c550>
../_images/59e0acc30c6663f69d0304260a776e6c1cf8a4f155d320f36172ab8271de9327.png

Remove clouds from TIR band#

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