📆 Project Period | November, 2023 |
📍 GitHub | gitlab.esa.int |
AI-based cloud and cloud shadow detection processor for Sentinel-2
🚀 This notebook explains how to use cloud mask processor on the Sentinel-2 products in Python scripts.
Before you start
Clone this repo, download the Sentinel-2 product you want to use, and create conda environment using environment.yml. Make sure that you have sub-tiling tool cm-vsm installed.
Import libraries
Create config dictionary
Adapt example config dictionary to your needs. Parameters that are needed to be changed are listed below:
- folder_name - folder name where Sentinel-2 SAFE product is located, e.g. "data"
- product_name - Sentinel-2 product name, e.g. "S2A_MSIL1C_20210608T103021_N0300_R108_T31TFJ_20210608T123816". Note that SAFE extension is not specified.
- level_product - Sentinel-2 product level, L1C or L2A
Create CMPredict class
cmf = KMPredict()
cmf.config_from_dict(config_dict, config_dict["product_name"])
cmf.sub_tile(path_out = cmf.product_cvat, aoi_geom = None)
cmf.predict()
cmf.mosaic()src= rasterio.open("prediction/S2A_MSIL2A_20200509T094041_N0214_R036_T35VLF_20200509T111504/L2A_T35VLF_20200509T094041_KZ_10m.tif")
plt.imshow(src.read(1))