2

I need to merge 13 GeoTIFFs with (RGB+alpha channel) into one, some of them touch each other. For tests I used only two of them. I was trying to use gdalbuildvrt tool and gdal_translate afterwards, but all I get is one raster with "white" space overlapping the other raster.

gdalbuildvrt mosaic.vrt c:\data\....\*.tif
gdal_translate -of GTiff -co "COMPRESS=LZW" -co "PREDICTOR=2" -co "BIGTIFF=YES" -co "TILED=YES" mosaic.vrt mosaic.tif

gdalbuildvrt failed raster merging

Then I figured out, that gdalbuildvrt doesn't support alpha-channel merging. It also seems that gdal_merge.py consumes too much memory to handle it (I have 64GB RAM). My last idea was to use gdal_translate. The processing stops with "-done" status, the output is 9,54 GB, but when opening in QGIS - it's empty.

gdalwarp -co COMPRESS=LZW -co PREDICTOR=2 -co BIGTIFF=YES c:\data\....\*.tif warped.tif

Is there any way to merge those overlapping rasters with alpha channels?

Agata
  • 31
  • 4
  • Try something similar than here https://gis.stackexchange.com/questions/401634/gdal-merge-ignore-nodata-value-only-if-present-in-all-bands-of-multiband-image/401685#401685. Run gdal_merge with -createonly first and then gdalwarp. I suggest to create the output as tiled. – user30184 Jun 28 '21 at 16:22
  • Your gdalwarp command should work. Copy just two adjacent images into a new directory and try again (that way testing is much faster). – user30184 Jun 28 '21 at 17:14
  • It's also not recommended to use compression with gdalwarp: https://gis.stackexchange.com/questions/89444/file-size-inflation-normal-with-gdalwarp – mikewatt Jun 28 '21 at 18:31

1 Answers1

1

I figured out how to make it:

  1. The best way is to use gdalbuildvrt with '-srcnodata 0' parameter. It solves the problem with overlapping "white" NoData raster parts. Next use gdal_translate to create GeoTIFF.

enter code here

gdalbuildvrt -srcnodata 0 mosaic.vrt c:\data\*.tif
gdal_translate -co COMPRESS=LZW -co PREDICTOR=2 -co BIGTIFF=YES -co TILED=YES mosaic.vrt merged.tif
  1. By using gdalwarp. This method creates bigger file (107 GB, first method gave me 96 GB raster) and longer processing.

    gdalwarp -co COMPRESS=LZW -co PREDICTOR=2 -co BIGTIFF=YES -co TILED=YES c:\data*.tif warped.tif

I was using GDAL 3.1.4 by OSGeo4W Shell

Agata
  • 31
  • 4