How to remove one or multiple bands using snappy

Hello all

I have to a band from several different products. For example, ‘band_1’ of each product needs to be merged. I have done this by (thanks to this forum):

(1) creating a ‘masterProduct’ which contains the first product (not just ‘band_1’ but the entire product),
(2) merging the ‘band_1’ of the rest of the products with ‘masterProduct’ in a for loop.

This gives me a final product which contains all the necessary bands but it also contains other bandw that I don’t need. How do I delete these unnecessary bands in python?

1 Like

Hello everyone,

I have almost the same question. After doing collocations, I have several “collocation_flags” bands which I want to remove.
I tried with the BandSelect operator, it doesn’t work.
Same goes with the Subset operator.
Maybe there is a parameter to change during collocation (targetProductType?), I don’t know.

Thank you in advance for your help!

EDIT: It’s working with the BandsExtractorOp operator.

It could be that it does not work because the flag bands are required by other bands. They probably reference it in the valid pixel expression.
To use the Subset operator, you would need to remove the expression first.

But it seems that the BandExtractor doesn’t check this dependency.
If this works for you, you found already a workaround.

1 Like