Snappy Merge bands


#1

Hi!
I’m try to merge 2 products. Each product has 1 band.
In the resulting product, I expect 2 bands, but there’s only one band.

red = ProductIO.readProduct(‘D:\tmp\T41VPD_20170603T065021_B04.jp2’)
green = ProductIO.readProduct(‘D:\tmp\T41VPD_20170603T065021_B03.jp2’)
sourceProducts= HashMap()
sourceProducts.put(‘masterProduct’, red)
sourceProducts.put(‘slaveProduct’, green)
parameters = HashMap()
target = GPF.createProduct(‘Merge’, parameters, sourceProducts)
bands = target.getBandNames()
print list(bands)

I’m setting the incorrect parameters?


#2

The reason is that the name within the inputs is the same. So only one wins. You can set more parameters.
Following how it can be done:
I assume that the names of the bands are simply ‘band_1’

NodeDescriptor = jpy.get_type(‘org.esa.snap.core.gpf.common.MergeOp$NodeDescriptor’)
include_1 = NodeDescriptor()
include_1.setProductId(‘masterProduct’)
include_1.setNamePattern(‘band_1’)
include_1.setNewName(‘red’)

include_2 = NodeDescriptor()
include_2.setProductId(‘slaveProduct1’)
include_2.setName(‘band_1’)
include_1.setNewName(‘green’)

included_bands = jpy.array(‘org.esa.snap.core.gpf.common.MergeOp$NodeDescriptor’, 2)
included_bands[0] = include_1
included_bands[1] = include_2

parameters.put(‘includes’, included_bands)


Snappy run maximum likelihood classification