Python nan data at terrain corrected image borders

Dear All,

in my code I running this portion :

        SAR_image = ProductIO.readProduct(source_file)

        HashMap = jpy.get_type('java.util.HashMap')    
        GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()

        parameters = HashMap()
        SAR_image_cal = GPF.createProduct('Calibration', parameters, SAR_image)
        #BandDescriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
         
        #SAR->Terrain_Correction-Ortorectification
        parameters = HashMap()

        parameters.put('mapProjection', 'EPSG:'+epsg_code)
    
        SAR_image_cal_terrain_corrected = GPF.createProduct('Terrain-Correction',parameters,SAR_image_cal)

It produces the terrain corrected image but at the borders of the image I would like to have NaN values instead of zeros…what can I apply for that?

Thank you

Fabiano

I can understand your need for the NaNs, but I think this is not possible, at least not with an option. Or is it @junlu?
You could post-process it. Maybe by BandMaths, this has the risk that you also turn other zeros into NaN. Maybe there is another indicator which can be used to find out when to replace a zero value. I don’t know the Terrain-Correction (I just looked at the code a bit). Maybe someone else can help?

OK thank you very much for the info, in this case I would like to have no data at the border of images ( right now I have dark pixel whose values are close to zero and I would like to get rid of them). What could I do for that?

Thank you

Fabiano

Normally I don’t work with SAR data, so I can’t be very helpful.
Maybe you can set this low value which you have at the border as no-data.

band = SAR_image_cal_terrain_corrected.getBand("band_name")
band.setNoDataValue(0.00132) # or what ever value
band.setNoDataValueUsed(true)

Maybe you ask in the S1TBX category for this because it is not related to python development, but to the SAR processing in general. I think more people will see your question and can help.

Use BandMaths in snappy or GPT, whichever method you use to set values below 0.004 or some threshold to 0.0 and set NaN value to 0.0 like @marpet. You can also change it this way to other NaN value but it is kinda funky but the 0.0 works quite nicely as I recall.

You might need to use couple of these separately to have it work properly, at least so it was at the version 2.0 of the Toolbox.
It means read product use operator write product close…rince and repeat.

Petr