RGB image/geotiff python

Hello everyone,

I’m trying to export an RGB / geotiff image with python because I want to open it with qgis but having some trouble. my script is:

 .....

    Rband=subset.getBand('B2')
    Gband=subset.getBand('B3')
    Bband=subset.getBand('B4')
    RGB=[Rband, Gband, Bband]

    image_info = ProductUtils.createImageInfo(RGB, True, ProgressMonitor.NULL)
    image_rgb = ProductUtils.createRgbImage(RGB, image_info, ProgressMonitor.NULL)

How can I save image_rgb in Geotiff format?

I did it for a single band with the follow script:

    ....

    parameters = HashMap()
    parameters.put('sourceBands', band_name)
    result = GPF.createProduct('Subset', parameters, subset)

    ProductIO.writeProduct(result, 'band_%s.tif' % (band_name), 'GeoTIFF')

Any ideas what I can do to export the RGB image?

Thanks,

Daniel

Just do the same as you have done for the single band. But add all three bands to the subset.

parameters.put(‘sourceBands’, ‘B2,B3,B4’)

Then you can create the RGB image in QGis .