Skip to main content

Is it possible to download cloud probabilities/cloud masks with the sentinelhub.py API ?

Yes. Hopefully following example will help:


from sentinelhub import SHConfig, BBox, CRS, SentinelHubRequest, bbox_to_dimensions, DataCollection, MimeType

bbox = BBox((8.688812,44.244215,9.307480,44.564056), crs=CRS.WGS84)
size = bbox_to_dimensions(bbox, 100)

clouds_evalscript = """
//VERSION=3
function setup() {
return {
input: ["CLM", "CLP"],
output: { bands: 2, sampleType: "UINT8" }
}
}
function evaluatePixel(sample) {
return [ sample.CLM, sample.CLP ];
}
"""

req = SentinelHubRequest(
evalscript=clouds_evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=('2021-02-25','2021-03-01'),
mosaicking_order='mostRecent'
)
],
responses=[SentinelHubRequest.output_response('default', MimeType.TIFF)],
bbox=bbox,
size=size,
)

masks = req.get_data()[0]

Using this I get CLM:
CLM


and CLP:
CLP


Thanks. Can I download it for a specific tile and date? Usually I grab specific bands in SAFE format:


date_parse='2019-04-28'
service = SafeTile(tile_name=tile_name, time=date_parse, aws_index=index, data_source=DataSource.SENTINEL2_L2A)
product_id = service.product_id
product_request = AwsProductRequest(product_id=service.product_id, tile_list=[gran],
bands=['R10m/B02', 'R10m/B03', 'R10m/B04',
'R10m/B08', 'R20m/B11', 'R20m/B12'],
metafiles=['metadata'],
data_folder=local_dir, safe_format=True)

CLM and CLP bands are not part of ESA files, and are only available through Sentinel Hub service.

They are produced using the model from sentinel2-cloud-detector. Pull requests to create said masks from downloaded SAFE files are welcome!

That being said, using service you can get CLM and CLP masks for any (specific) date and bounding box.

Best


Reply