Hi @marpet , thanks for your patience and help on this. I am still trying different approaches as couldn’t get script to read the mask into an array.
I have tried
So i tried:
geom_mask = src_product.getMaskGroup().get(geom_name)
valid_mask_image = geom_mask.getValidMaskImage()
and got the error:
AttributeError: 'org.esa.snap.core.datamodel.ProductNode' object has no attribute 'getValidMaskImage'
Given that i need to call readValidMask() on a band and not a mask, I have then tried your following advice:
I wrote it as (after mask_array, and before the invalid_mask):
src_band.setValidPixelExpression(str(geom_name) +'== 0')
src_band.setNoDataValue(np.nan)
src_band.setNoDataValueUsed(True)
src_band.getValidMaskImage()
#read the mask pixels into an mask array
src_band.readValidMask(0, 0, w, h, mask_array)
I get the error:
src_band.readValidMask(0, 0, w, h, mask_array)
RuntimeError: no matching Java method overloads found
Also, in this approach, I cant see how to use the geom_mask, or is it even necessary?
geom_mask = src_product.getMaskGroup().get(geom_name)
Thanks again!
P.S. OK that I also changed the name of the thread to make it more specific to the problem?