I am confused how to extract a valid mask for sentinel 1 acquisitions. Looking into the forum, I see it should exist a method readValidMask… What I do is the following:
from snappy import ProductIO
file_name = 'S1B_IW_GRDH_1SSH_20171023T121033_20171023T121058_007956_00E0E1_2C5C.SAFE.zip'
source = ProductIO.readProduct(file_name)
However the method does not exist. How can I load a valid pixel mask, that I can later mask out no data pixels?
Many thanks marpet that helped me to move quite a bit. Just for code completeness for future users I provide a working example and how to define the data array that we want to populate.
source = ProductIO.readProduct(filename)
w = source.getSceneRasterWidth()
h = source.getSceneRasterHeight()
band = source.getBand('Amplitude_HH')
mask = band.readValidMask(0,0,w,h,np.zeros(shape=(w,h), dtype=np.uint8))
At this point mask is a two dimensional array w x h.
I tried to do the same thing to get the actual data
Band = ProductData.createInstance(np.zeros((w, h), np.float32))
band.readRasterData(0,0,w,h,Band)
for some reason it seamed that I needed to instantiate my empty array with the ProductData.createInstance method.
Now if I use Band.getElems() that returns a vector instead of an array. How can I retrieve the actual data array (or convert from the vector to the appropriate 2D array)?
I though that there was a complicate way how the array was represented as a vector…
I still though have the feeling that I miss something. The mask looks a bit weird. Here is the code and the images I got.
Method: I warped an ESA sentinel1 sar file and named it out.tif. I opened the non-warped and retrieved the valid mask. I then save the mask as geotiff including georeference from the warped file.