Following this post Obtaining sigma (backscatter) from Sentinel 1 subset I rewrote the method to this:
def write_rgb_image(bands, filename):
polarisation = 'B2'
src_product = ProductIO.readProduct(filename)
width = src_product.getSceneRasterWidth()
height = src_product.getSceneRasterHeight()
tar_product = Product("target", 'GeoTIFF', width, height)
band_names = src_product.getBandNames()
BSelectOp = BandSelectOp()
BSelectOp.setParameterDefaultValues()
BSelectOp.setSourceProduct(src_product)
BSelectOp.setParameter('selectedPolarisations', polarisation)
BSelectOp.setParameter('sourceBandNames', band_names)
BSelectOp.setParameter('bandNamePattern', '^(B2|B3|B4|B8)$')
target_product = BSelectOp.getTargetProduct()
ProductIO.writeProduct(target_product, 'test', 'GeoTIFF')
I’m getting a java.lang.NullPointerException
and I don’t get why because I have set all the parameter of BandSelectOp