Unable to get Mask from Sentinel 2 image with snappy


#1

Hello everyone:

I am trying to get the ‘scl_water’ mask for every image I process. First I resample and reproject the image and then I run the following code:

mask_group = product.getMaskGroup()
mymask = mask_group.get(‘scl_water’)
my_real_mask = jpy.cast(mymask, Mask)
h = product.getSceneRasterHeight()
w = product.getSceneRasterWidth()
data = np.zeros(w * h, np.int32)
data.shape = h,w
my_real_mask.readPixels(0,0,w,h, data)

However, every element in data remains 0. I made the same operations with SNAP Desktop and there wasn’t any problem.

Does anyone know what is the problem?

Thanks


#2

Hi @Borkadd,

Did you make any progress with this?

Reading masks was working fine for me based on previous advice from @marpet (same as you have it) but now it seems to be broken… not sure if this was caused by some kind of update.

Cheers,

Sam