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?
Best Answer
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.
The only problem is, that only first band from all files will be added. This simply fixed by editing vrt file.
Raster VRT format tutorial: http://www.gdal.org/gdal_vrttut.html