4

I export bunch of DEM files (10000x5000) from Photoscan and I need to combine them with gdal_merge.py but the problem is that it consumes all the memory availible and can't finish processing.

What workaround can be applied to limit RAM usage?

1 Answer 1

5

gdal_merge allocates memory for whole raster at once so it runs quickly for datasets that fit into memory. If it is not you case, use gdalwarp tool which does tiling so you can control how much memory does it use:

gdalwarp --config GDAL_CACHEMAX 512 -wm 4096 merged.tif

where GDAL_CACHEMAX is memory for IO cache and -wm is memory limit which controls the tile size. Both are in MB.

2
  • For helping GDAL to write the large output file create it absolutely as tiled -of GTiff -co tiled=YES. -wm 4096 feels quite large value trac.osgeo.org/gdal/wiki/UserDocs/GdalWarp. -wm 500 may be better but it is easy to test with your data and computer.
    – user30184
    Commented Nov 2, 2016 at 14:40
  • There's also the approach in this answer of creating a virtual mosaic using gdalbuildvrt mosaic.vrt *.tif then converting using gdal_translate -of GTiff mosaic.vrt mosaic.tif (and using -co to apply relevant creation options for the output tiff
    – tlrss
    Commented Jan 22 at 14:54

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.