6

I would like to use GDAL (under Windows; OSGeo4W Shell) to merge all GeoTIFFs from one directory into a new GeoTIFF. I have tried to address them by writing c:\data\....\*.tif which however does not seem to work, using the Windows environment.

I am looking for the most practicable way to perform this operation; if possible completely within the OSGeo4W Shell. Addressing every single mosaic part name 'by hand' in the Shell is not an option.

  • 2
    Please write the full command you used and provide more details about the results obtained using that command. – Techie_Gus Mar 2 '17 at 16:18
  • ...also quote the error message – MappaGnosis Mar 2 '17 at 16:25
  • What tool? gdal_merge? – Mike T Mar 2 '17 at 20:28
13

You could create a virtual mosaic from all Tiff files:

gdalbuildvrt mosaic.vrt c:\data\....\*.tif

and convert it afterwards:

gdal_translate -of GTiff -co "COMPRESS=JPEG" -co "PHOTOMETRIC=YCBCR" -co "TILED=YES" mosaic.vrt mosaic.tif

Keep an eye on all the GDAL creation parameters to compress your mosaic and use gdaladdo to add overviews.

More info here: GeoTiff Compression for Dummies - Paul Ramsey

  • Just a small hint: increasing GDAL_CACHEMAX could bring a performance boost. On Windows: set GDAL_CACHE_MAX=128 or gdal_translate --config GDAL_CACHE_MAX 128 -co "COMPRESS=JPEG" ... – christoph Mar 5 '17 at 11:17
  • Does the same command work for Linux? – wondim May 6 at 18:49
0

If you are willing to use python, then you can use wildcards to select files with the glob module, and then you can execute the command with os.system.

import glob
import os

file_list = glob.glob("c:\data\....\*.tif")

files_string = " ".join(file_list)

command = "gdal_merge.py -o output.tif -of gtiff " + files_string

os.system(command)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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