ProductIO adding bands

Hi,

I’m creating a python algorithm to detect clouds and clouds shadows oversea for Sentinel 2 images. I use ProductIO.readProduct(“filepath”) to open and use the desired file. After performing some operations I would like to add new bands with some conditions and I use BandMathsOp$BandDescriptor. Is there a way to add these created bands to my existing product? I know it is possible to create and write a new product, but I would like the new bands to be added.

Thank you.

You should be able to call addBand from the product. Note that if you are using virtual bands from BandMaths, not all exports will support this. If you write the product as dimap, it should save all the bands.