2

Already read Merge Multi-Band Geotiff with different datatypes (with gdal) but can't apply that solution so please do not flag as duplicate.

I have near 3.000 geotiff files that I need to merge into just one.

this is what I done so far:

gdalbuildvrt -input_file_list list_of_files.txt -overwrite -addalpha images.vrt

and then

gdal_translate -tr 0.000170 0.000170 -r cubicspline -of GTiff images.vrt test.tif

I've got this warning:

Warning 1: Unable to export GeoTIFF file with different datatypes per different bands. All bands should have the same types in TIFF.

I can get rid of the warning when remove -addalpha from gdalbuildvrt.

I'm a complete newbie on this so I ask: What is the implication of the -addalpha parameter and that warning if I choose to keep it?

3

From docs:

-addalpha: Adds an alpha mask band to the VRT [...] The alpha band is filled on-the-fly with the value 0 in areas without any source raster, and with value 255 in areas with source raster

The alpha channel is added as a Band of type byte, while the rest of your files are probably a different Type (e.g. UINT16). Like that you cannot combine them in one GeoTiff.

Best option would be to create a mask from the alpha channel.

When you have an RGB image:

gdal_translate -tr 0.000170 0.000170 -r cubicspline -b 1 -b 2 -b 3 -mask 4 -of GTiff images.vrt test.tif

When you have a Single-band image:

gdal_translate -tr 0.000170 0.000170 -r cubicspline -b 1 -mask 2 -of GTiff images.vrt test.tif

If you don't know the band numbers, find out after creating the VRT with this command:

gdalinfo images.vrt

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.