I would like to call gdal_merge via batch-file, so far this looks like this:
python "C:\Program Files\GDAL\gdal_merge.py" -ot Float32 -of GTiff -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 -o "H:\test.tif" "H:\raster1.tif" "H:\raster2.tif"
This works already when I manually put the file names like above. Is there a way to automatically get all .tif-files in the folder as arguments?
Original post:
I want to automate the gdal_merge of 8 raster files (.tif) that are in the same folder using a high compression profile. Preferably I would like to use either python or a batch file.
My first try using python is based on a online tutorial:
from osgeo import gdal
import os
import subprocess
in_folder = r'C:\d2'
filelist = os.listdir(in_folder)
cmd = 'gdal_merge.py -ot Float32 -of GTiff -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 -o C:/Users/HYWA163/Documents/test.tif'
subprocess.call(cmd.split() + filelist)
Here I get the error "OSError: [WinError 193] %1 is not a permitted Win32 application"
Does anybody have an idea where the error is coming from or an alternative way of automating this merge outside of QGIS?