Number of clear sky Sentinel-2 observation

I am looking for a way to get number of sentinel-2 images per pixel over a period, which are not affected by cloud.
So, the procedure would be first masking cloudy pixels of a Sentinel-2 stack (for instance using SLC band), then generating daily composites per day (aggregate_temporal_period(“day”,reducer=“median”)). Now, we should have a Sentinel-2 stack of non-cloudy pixels. Finally, counting the number of non-cloudy images per pixel from the stack using sum function.

Just as an example, if there are 8 observations (non-cloud) for pixel #1 from different days in 2 months, then the number of clear sky observation is 8 for this pixel. And in the same stack, if 3 of the observations are cloudy for pixel #2 , the value is 5 for pixel #2.

Mohammad

Hi,

Have you tried converting the SCL layer to a 0 or 1 image and then aggregating over time with count or sum? I don’t have an example by hand.

(We had a prolonged weekend, I am still catching up to your comments)

Greetings,
Emile Sonneveld

You might be interested in the Best Avilable Pixel code:
https://documentation.dataspace.copernicus.eu/APIs/openEO/openeo-community-examples/python/RankComposites/bap_composite.html

It will for each pixel sample the day in a way it avoids clouds as much as possible.