In QGIS when I merge two images with 3 and 5 bands respectively via Raster >> Miscellaneous >> Merge
with the option checked on place each input into a separate band it resulted in a merged image that has 8 bands which is what I wanted.
Now I want to replicated this result in python/GDAL, but it doesn't give me same result. Instead it returns a merged image with just 2 bands not 8 bands. My code is below:-
from osgeo import gdal
img_list = ['img1.tif', 'img2.tif']
vrt = gdal.BuildVRT("merged.vrt", img_list, separate=True)
gdal.Translate('merge_img.tif', vrt)
Best Answer
As mentioned in the other answer :
the workaround in command line is a bit long but it works: It consists in making two sets of 1 band images before you merge them