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.
No, this was not solved, but i found a way to bypass it by reading each pixel of the mask inside a double loop for (I know, quite inefficient), as shown below
mask_group = product.getMaskGroup().get(‘scl_cloud_medium_proba’)
mymask = jpy.cast(mask_group, Mask)
h = product.getSceneRasterHeight()
w = product.getSceneRasterWidth()
data = np.zeros(w * h, np.int32)
data.shape = h,w
final_mask_medium = mymask.getSourceImage().getData()
//Double loop after this
However, I have problems again. The last line before the loop gives a NullPointerException, so I can´t acces it, although there is no problem accesing mymask.getSoruceImage() . The problem is in getData()
Another issue I found that I think is related to this one is that when I try to extract some bands from the image, it gives the same NullPointerException in the function ReadPixels() as shown below:
Thanks @Borkadd. Yeah, looping through all the pixels is not really feasible as a solution for me because it would be too slow for the processing I need to do. For now I managed to find an old installation of snap where my old code still works… so will continue to use that until the issue resolved.
Hi @shunt16 , Finally I did It with GPT, calling It from a Python script. It takes far less time than doing It directly with Python, with or without loop.
Hello, i’m new here and i’ve been having challenges trying to get SNAP to produce for me images that have been Atmospherically corrected. How do i extract the corrected images from SNAP?
Hi @Borkadd, how did you do it exactly? I’m trying using snappy but I am stuck at the same point as the previous comments to obtain the information of the mask.
Hi,
For the new version snappy, cast to Java Mask may return zeros array, so you can cast Java ProductNode to Java Band, rather than Java Mask. My version is SNAP9.0-snappy, and data is sentinel2
for example:
from snappy import Band
mask_java = jpy.cast(source_product.getMaskGroup().get(“opaque_clouds”), Band)
I don’t know if other posts have already solved this problem, hope this method can help you