Hello all
I am using the following BandMaths expression in snappy:
‘if CI_20021019!=NaN and CI_20021022!= NaN then max(CI_20021019,CI_20021022) else 0’
Essentially, I want to compute max value of two bands only if a pixel contains non-NaN values in both both bands, otherwise I want the pixel value to be zero. However, the expression above assigns NaN instead of 0 in else condition.
The following is the code I used:
targetBand = BandDescriptor()
targetBand.name = ‘composite_CI’
targetBand.type = ‘float32’
targetBand.expression = ‘if (’+CI_bandnames[0]+’!=NaN and ‘+CI_bandnames[1]+’!= NaN) then ‘+‘max(’+CI_bandnames[0]+’,’+CI_bandnames[1]+’)’+’ else 0’
targetBands = jpy.array(‘org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor’, 1)
targetBands[0] = targetBand
params = HashMap()
params.put(‘targetBands’, targetBands)
CI_prod = GPF.createProduct(‘BandMaths’, params, product)
Please let me know where am I making a mistake?