GDAL Raster Merge – How to Merge Thousands of Rasters with gdal_merge.py

gdalmerge

I have several thousands of small rasters, kb size, tens or hundreds of pixels most of them. Batch command of gdal_merge.py can't take all the files at once, so I am doing partial merges of chunks of 500 images, and that's relatively fast.

But when I try to merge the partial merges it takes way too much. In one even gdal_merge.py gave up and returned Killed.

Has anyone experienced something similar, and found an optimization?

Alternatives to gdal_merge.py are welcome

Best Answer

You can create a vrt file with gdalbuildvrt or gdal_merge.py -of VRT and then run gdal_translate -of GTiff on that VRT.

Like this, I had much faster results compared to gdal_merge with huge files.

See this answer to a similar question:

gdal_merge.py loads all files into memory before processing them. therefore it is not able to process large files if your memory is small. see here.