[Gdal-dev] Merging really large images to one huge

Ken Boss Ken.Boss at dnr.state.mn.us
Fri Sep 2 10:34:57 EDT 2005


>>> "Morten Nielsen" <mn at blominfo.dk> 9/2/2005 5:03 AM >>>
Hi there

I'm trying to merge some large tiles (~5gb) to one big image (~30gb)
using gdal_merge.py, before I can compile it to ECW.
Here is what happens, when only merging just two of the tiles:

 D:\>python "c:\Program Files\FWTools0.9.9\bin\gdal_merge.py" -o 6220.tif
6220_1.tif 6220_2.tif
Traceback (most recent call last):
  File "c:\Program Files\FWTools0.9.9\bin\gdal_merge.py", line 468, in ?
    fi.copy_into( t_fh, band, band, nodata )
  File "c:\Program Files\FWTools0.9.9\bin\gdal_merge.py", line 285, in
copy_into
    nodata_arg )
  File "c:\Program Files\FWTools0.9.9\bin\gdal_merge.py", line 118, in
raster_copy
    t_xsize, t_ysize, t_band.DataType )
  File "C:\PROGRA~1\FWTOOL~1.9\pymod\gdal.py", line 845, in ReadRaster
    buf_xsize, buf_ysize,buf_type)
MemoryError
 
The tiles are spatially adjacent.
 
Any ideas are appreciated.

Best regards
/Morten Nielsen

*------------------------------------------------------------------------------

Morten--

I think the problem here is that gdal_merge.py reads the entirety of each input file into memory before writing it to the output file.  Frank has recently added a -createonly switch to gdal_merge that will simply initialize the output file, allowing you to then employ the gdalwarp utility to mosaic your inputs into that output file.  See http://lists.maptools.org/pipermail/gdal-dev/2005-August/006221.html.

Another approach might be to skip the physical mosaicking of your inputs altogether, creating a VRT file to describe the mosaic instead, and then using that as input to gdal_translate to create your .ecw output.  I have successfully used this approach to create ~175000x225000 RGB ecw mosaics, but trying to push much beyond that has led to memory errors as well.

Gabriel Ebner posted a modified version of gdal_merge that will output VRT files a while back.  You can find it at http://lists.maptools.org/pipermail/gdal-dev/2005-May/005691.html.

HTH,

--Ken Boss
  MN DNR Forestry






More information about the Gdal-dev mailing list