When I run the BandMaths in snappy I only get the single band that I calculated. How do I get a product that retains all the bands in the product, plus the new calculated one?
BANDDESCRIPTOR = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
band = BANDDESCRIPTOR()
band.name = b_name
band.type = b_type
band.expression = b_expression
product = ProductIO.readProduct(input)
targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1)
targetBands[0] = band
parameters = HashMap()
parameters.put('targetBands',targetBands)
result = GPF.createProduct('BandMaths',parameters,product)
Do I need to add all the existing bands to the targetBands HashMap?
- Count the bands in the product
- Create a HashMap of that length, plus 1 for the new band
- Add all the bands, expression is just the band
- Add the new band to the HashMap
- Then createProduct?