Each pixel in the land cover mask has a value between 0-11. Each value corresponds to a particular class of land cover. Water’s class index is 6. We can use this class index to extract the water mask. First, we count the number of pixels that are marked as water. Next, we multiply that number by the area that each pixel covers to get the surface area of the water. Depending on the bands, the spatial resolution of a Sentinel-2 L2A image is 10m , 20m , or 60m . All bands are downsampled to a spatial resolution of 60 meters for the land cover segmentation model inference. As a result, each pixel in the land cover mask represents a ground area of 3600 m 2, or 0.0036 km 2.
os.makedirs(overlay_dir, exist_ok=True) lake_areas = [] mask_dates = [] for image_file, mask_file in zip(image_files, mask_files): image_file.split(”/”)[-1].split(”_TCI”)[0] mask_file.split(”/”)[-1].split(”.tif”)[0] mask_id.split(”_”)[2] f”{image_id}{mask_id}” tifffile.imread(image_file) 1830), interpolation=cv2.INTER_LINEAR) [6]).astype(np.uint8)  # water has a class index 6 60 / (1000 * 1000)  # calculate the surface area cv2.findContours(water_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contour, -1, (255, 0, 0), 4) mask_date + ”.png” cv2.cvtColor(lake_crop, cv2.COLOR_RGB2BGR))