[GIS] gdal_merge.py with single band raster

gdalgdal-mergeimagerymosaicraster

I'm trying to mosaic the True Marble world imagery 250M geotiffs using gdal_merge.py though one of them doesn't have RGB bands like the rest and gdal_merge fails (same number of bands is listed as a requirement in it's documentation). This is the error I get:

python.exe : ERROR 5: TrueMarble.250m.21600x21600.B4.tif: GDALDataset::GetRasterBand(2) - Illegal band #

This is the tile causing the issue: TrueMarble.250m. 21600x21600.B4

Should I use a different mosaic tool or should I try to coerce the tile into the format gdal_merge requires somehow?

Best Answer

I ran across this mosaicing the True Marble imagery as well, though I used gdalbuildvrt and then gdal_translate. From memory, the recalcitrant tiffs are stored as a single band with a color table.

Just convert them to 3 band RGB with gdal_translate:

gdal_translate -expand rgb TrueMarble.250m.21600x21600.B4.tif TrueMarble.250m.21600x21600.B4.RGB.tif
Related Question