S2 SCL layer dilation

Dear APEx devs,
i try to dilate the S2 SCL cloud layer (on cdse backend) using this code:

scl = con.load_collection(collection_id="SENTINEL2_L2A", [...], bands=['SCL'])
s2_cube = con.load_collection(collection_id="SENTINEL2_L2A", [...], bands=[...])

cond_scl_cloud = ((scl == 3) | (scl == 8) | (scl == 9) | (scl == 10))

# dilation
k = 11
kernel = array_create([[1.0] * k for _ in range(k)])
dilated_mask = cond_scl_cloud.apply_kernel(kernel=kernel).multiply(1.0)
dilated_mask = (dilated_mask > 0).multiply(1.0)

# masking
b02_masked = s2_cube.band("B02").mask(dilated_mask)
return b02_masked 

Using the original scl mask, the B02 looks like expected:

However, using the dilated mask, there are weird artifacts appearing:

I tried casting in various places (as suggested by another thread), but so far without success :slight_smile: Could you help me here? Thanks in advance

Could you provide me with the actual spatial/temporal extent that you’re using @paul.karlshoefer ?

Of course:

"spatial_extent": { "west": 11.60, "south": 48.50, "east": 12.0, "north": 48.9, "crs": "EPSG:4326"},
"temporal_extent": ["2023-02-06", "2023-02-20"],

the image shown is the masked B02 Band from the first item in this collection:
b02_masked.reduce_dimension(dimension='t', reducer="first")

Works for kernel sizes 3-9 but goes haywire from 11 on. This looks like a bug.

How urgent is this?

To keep track of this I’ve created this issue: visual artifacts for apply_kernel with size >= 11 · Issue #604 · Open-EO/openeo-geotrellis-extensions · GitHub

Thank you, I commented in the Github issue, because the behaviour is also strange with k < 11. I put the details there.