Monday, November 16, 2015

Mosaic a large number of GeoTiff images using GDAL

GDAL's gdalwarp function can be used to combine geo-referenced images into a large mosaic file. For a few files, it is relatively straightforward to type the input images in the command line, e.g.
C:> gdalwarp input1.tif input2.tif output.tif
A large number of images for merging

If there are a large number of input files, as shown in the screenshot above, then a wildcard can be used, e.g.
C:> gdalwarp input*.tif output.tif

Alternatively, you can generate a list of input files and pass it to the gdalwarp as an argument as shown below. Then run the command.

  1. In a command prompt, type in the following.

    C:> cd \path\to\input_images
    C:> dir /o/b *.tif > list.txt

    The list is created.

  2. To use the list, use the --optfile argument in the gdalwarp command.

    C:> gdalwarp -multi -wm 1000 --optfile list.txt output.tif

    Note: the -multi argument tells gdalwarp to use multiple processing threads.
    The -wm 1000 tells gdalwarp to grab 1000 mb or memory for processing

    The images in the list are merged into the output.tif file.

No comments:

Related Posts with Thumbnails