I have three geotiffs:

  • orthomosaic.tif: a multispectral orthomosaic with three channels:

    Band 1 Block=512x512 Type=Byte, ColorInterp=Red
    Band 2 Block=512x512 Type=Byte, ColorInterp=Green
    Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
    Band 4 Block=512x512 Type=Byte, ColorInterp=Undefined
  • DTM.tif (Digital Terrain Model) and DSM.tif (Digital Surface Model) of the same extent with one band each:

    Band 1 Block=5001x1 Type=UInt16, ColorInterp=Gray

I want to merge those three into one single file (to consequently retile them and work with smaller tiles having all six channels). This works fine with this command where the parameter -seperate preserves the bands and -o stands for "output":

gdal_merge.py -o merged_file.tif -separate  orthomosaic.tif  DTM.tif  DSM.tif
  • Output is: merged_file.tif

    Band 1 Block=10002x1 Type=Byte, ColorInterp=Gray
    Band 2 Block=10002x1 Type=Byte, ColorInterp=Undefined
    Band 3 Block=10002x1 Type=Byte, ColorInterp=Undefined
    Band 4 Block=10002x1 Type=Byte, ColorInterp=Undefined
    Band 5 Block=10002x1 Type=Byte, ColorInterp=Undefined
    Band 6 Block=10002x1 Type=Byte, ColorInterp=Undefined

Problem is: The script converts all channels to Type=Byte, which makes the DTM/DSM channels Type=UInt16 useless for me.

Question is: Is it possible to have different data types in different bands in a single geotiff file? And how do I do this when merging several geotiffs?

1 Answer 1


You can try to use gdalbuildvrt (http://www.gdal.org/gdalbuildvrt.html) instead of gdal_merge.py. As the result the xml-like file describing virtual raster created. GDAL and QGIS works with this file.

gdalbuildvrt qqv.vrt -separate qq1.tif qq3.tif

The only problem is, that only first band from all files will be added. This simply fixed by editing vrt file.

$ gdalinfo qqv.vrt 
Driver: VRT/Virtual Raster
Files: qqv.vrt
Size is 735, 547
Coordinate System is:
GEOGCS["Unknown datum based upon the WGS 84 ellipsoid",
    SPHEROID["WGS 84",6378137,298.257223563,
Origin = (513165.703783421427943,5016826.563432835973799)
Pixel Size = (59.969933184855272,-60.001568937759295)
Corner Coordinates:
Upper Left  (  513165.704, 5016826.563) (Invalid angle,Invalid angle)
Lower Left  (  513165.704, 4984005.705) (Invalid angle,Invalid angle)
Upper Right (  557243.605, 5016826.563) (Invalid angle,Invalid angle)
Lower Right (  557243.605, 4984005.705) (Invalid angle,Invalid angle)
Center      (  535204.654, 5000416.134) (Invalid angle,Invalid angle)
Band 1 Block=128x128 Type=Byte, ColorInterp=Undefined
  Min=0.000 Max=255.000 
  NoData Value=nan
Band 2 Block=128x128 Type=Byte, ColorInterp=Undefined
  Min=0.000 Max=255.000 
  NoData Value=nan
Band 3 Block=128x128 Type=Byte, ColorInterp=Undefined
  Min=0.000 Max=255.000 
  NoData Value=nan
Band 4 Block=128x128 Type=Int16, ColorInterp=Undefined

Raster VRT format tutorial: http://www.gdal.org/gdal_vrttut.html

  • Thank you for your answer, I didn't know of the vrt-tool and for my purpose it might work, since I might not need actual .tif files (this delivers .vrt-files). To be clear: I'm still wondering whether it is possible to save different types per band in a single .tif? Also, on my dataset the vrt-tool gave me warnings (Warning 6: gdalbuildvrt does not support heterogenous projection) and an error (ERROR 1: Failed to write .vrt file in FlushCache().) I ended up with the workaround (convert to Float32, since I normalize to 0-1 range later anyways).
    – Honeybear
    Aug 16, 2016 at 12:46
  • 2
    1. The warning told that you have different spatial references (need to be fixed via reprojecting) and error told that the destination path for vrt is not writable. 2. gdal_merge.py has no option to allow different types of bands. 3. As I know GeoTIFF not support bands with different types, Erdas Imagine (*.imd, HFA) may be. Aug 16, 2016 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.