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

  • 4
    You can try to create a vrt file with gdalbuildvrt and gdal_translate -of GTiff on that VRT. I had faster results comparted to gdal_merge with huge files.
    – pLumo
    Dec 17, 2018 at 15:21
  • does it need to be with gdalbuildvrt or can be also done with gdal.Warp?
    – ImanolUr
    Dec 17, 2018 at 15:58
  • No, a vrt file derived from gdal_merge.py -of VRT is fine too as input.
    – pLumo
    Dec 17, 2018 at 15:59
  • Wow, I was not expecting such an improvement. I was a bit afraid because in the own documentation says that it might overwrite data with nodata, but it seems it worked. Do you want to write it as an answer so I accept it?
    – ImanolUr
    Dec 17, 2018 at 16:37

2 Answers 2


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.


If you manage to open all the rasters in QGIS 2.18 you can try QTiles plugin and merge them into the only one file with an extension *.mbtiles.

  • Right now i need the output as a tiff, or I should change some steps further, but I keep it as an option of other methods fail
    – ImanolUr
    Dec 17, 2018 at 15:59
  • When you open *.mbtiles layer in Qgis you can then save it as *.tif
    – Vadym
    Dec 17, 2018 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.