Version 7 (modified by 15 years ago) ( diff ) | ,
---|
The gdal_merge
utility
A python script to mosaic a set of images The official documentation for gdal_merge is at http://www.gdal.org/gdal_merge.html.
gdal_merge.py uses nearest neighbour resampling. If you want control over the resampling used, you should use gdalwarp instead.
Are there other ways of getting a list of images into gdal_merge without putting them all on the command line?
Method 1, use --optfile
flag to specify a text file of a directory listing of each file to merge.
It can be created in Windows by typing:
`dir /b /s *.tif > tiff_list.txtt`
or on unix by typing:
ls -1 *.tif > tiff_list.txt
Then you summon gdal_merge like:
python gdal_merge.py -n 0 -v -o mosaic_31.tif --optfile tiff_list.txt
Method 2, use a batch file wrapper, see attached. (for windows)
Create an RGB image by merging 3 different greyscale bands
Conduct "merging by stacking" with the -separate flag. So if you had three greyscale files that cover the same area and you do:
gdal_merge.py -separate 1.tif 2.tif 3.tif -o rgb.tif
This maps 1.tif to red, 2.tif to green and 3.tif to blue.
Specify overlap precedence
The last image in the input line comes out on top of the finished image stack. You might also be need to note which color (value) is should not be copied into the destination image if it is not already defined as nodata
.
gdal_merge.py -0 merge.tif -of GTiff -n 0 \ image1.tif image2.tif image3.tif image4.tif
Attachments (1)
-
gdal_wildmerge.bat
(1.4 KB
) - added by 16 years ago.
windows batch file to merge using wildcards
Download all attachments as: .zip