cloud_mask#
Module for computing cloud-mask from a sen2cor clouds classification raster.
- sen2chain.cloud_mask.max_dtype_value(dtype: dtype)#
Returns the numpy dtype maximum value.
- sen2chain.cloud_mask.mask_footprint(raster_band: str | PosixPath, footprint: List[float], out_path: str | PosixPath = './footprint_masked.tif') None#
Masks a raster band with a footprint.
- Parameters:
raster_band – path to the raster band.
footprint – footprint.
out_path – path to output.
- sen2chain.cloud_mask.katana(geometry: Polygon | MultiPolygon, threshold: int = 2500, count: int = 0) List[Polygon]#
Splits a Polygon into two parts across it’s shortest dimension recursively
- Parameters:
geometry – polygon or multipolygon to split.
threshold – maximum value of the widest dimension.
count – number of iterations.
- sen2chain.cloud_mask.erosion_dilatation(features: Sequence[Dict], threshold: int = 2500, erosion: int = -20, dilatation: int = 100) Dict#
Erosion then dilatation.
- Parameters:
features – list of GeoJSON like objects.
threshold – maximum value of the widest dimension of the features.
erosion – size of the outer buffer.
dilatation – size of the inner buffer.
- sen2chain.cloud_mask.create_cloud_mask(cloud_mask: str | PosixPath, out_path='./cloud_mask.tif', buffering: bool = True, erosion: int | None = None, dilatation: int | None = None) None#
create cloud mask uint8
- Parameters:
cloud_mask – path to the cloud mask raster.
out_path – path to the output.
buffering – if true, computes erosion/dilation.
erosion – size of the outer buffer.
dilatation – size of the inner buffer.
- sen2chain.cloud_mask.create_cloud_mask_v2(cloud_mask: str | PosixPath, out_path='./cloud_mask_v2.jp2', erosion: int = 1, dilatation: int = 5) None#
Create cloud mask :param cloud_mask: path to the cloud mask raster. :param out_path: path to the output. :param erosion: size of the outer buffer in px. :param dilatation: size of the inner buffer in px.
- sen2chain.cloud_mask.create_cloud_mask_b11(cloud_mask: str | PosixPath, b11_path: str | PosixPath, out_path='./cloud_mask_b11.jp2', dilatation: int = 5) None#
Marking cloud mask v2 with B11 values to reduce overdetection of clouds for some specific water bodies (uint8).
- Parameters:
cloud_mask – path to the cloud mask raster (sen2chain).
b11_path – path to the l2a b11.
out_path – path to the output.
erosion – size of the outer buffer in px.
dilatation – size of the inner buffer in px.
- sen2chain.cloud_mask.create_cloud_mask_v003(cloud_mask: str | PosixPath, out_path='./CM003.jp2', probability: int = 1, iterations: int = 1) None#
Create cloud mask version cm003. This cloudmask uses a simple thresholding and dilatations over the 20m cloud_probability band from Sen2Cor. The threshold value and number of dilatation cycles can be manually modified by the user. Default values 1% and 5 cycles. :param cloud_mask: path to the 20m cloud mask raster. :param out_path: path to the output file. :param probability: threshold in percent for the 20m cloud_probability band binarisation. :param iterations: number of dilatation cylces to apply.
- sen2chain.cloud_mask.create_cloud_mask_v004(scl_path: str | PosixPath, out_path='./CM004.jp2', iterations: int = 1, cld_shad: bool = True, cld_med_prob: bool = True, cld_hi_prob: bool = True, thin_cir: bool = True) None#
create cloud mask version cm004. This cloudmask uses 20m resolution SCL image from Sen2Cor. The number of dilatation cycles can be manually modified by the user. Default value: 5 cycles. :param scl_path: path to the Sen2Cor 20m scene classification raster. :param out_path: path to the output file. :param iterations: number of dilatation cylces to apply. :param cld_shad: usage of the CLOUD_SHADOWS (3) :param cld_med_prob: usage of the CLOUD_MEDIUM_PROBABILITY (8) :param cld_hi_prob: usage of the CLOUD_HIGH_PROBABILITY (9) :param thin_cir: usage of the THIN_CIRRUS (10)