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’)
parameters = HashMap()
target = GPF.createProduct(‘Merge’, parameters, sourceProducts)
bands = target.getBandNames()
I’m setting the incorrect parameters?
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_2 = NodeDescriptor()
included_bands = jpy.array(‘org.esa.snap.core.gpf.common.MergeOp$NodeDescriptor’, 2)
included_bands = include_1
included_bands = include_2
I think the topic of my question fits in this discussion:
Same scenario to merge two tiff files but I need to rename the band names of one of the files, what is the simplest way to do it?
I do the “merge” and it works absolutely fine, I think there must be kindof parameter setting to avoid re-opening the outcome file and rename bands with “BandMaths”, Is there?
You can use the newName paramter to change the name of an included band.
Like in my post above.
There band_1 is renamed to red from the first product and band_1 is renamed to green from the second product.
And you can always combine multiple operators. So there is no need to close and reopen the products.
Maybe you are not working with python or on the command line?
I got it done.
I am new to SNAP and still in the exploration phase
In fact I am working on python but preferred to do the merge & rename in one shot, as you explained here.