0

While merging the files using gdal_merge.py the following code works:

subprocess.call([sys.executable,gmerge,'-o','C:\\r.tif','-of','GTiff','D:\\a.tif','D:\\b.tif'],shell=True)

However, when the input files are numerous, each file can not be inserted separately. In this case, the following code does not work:

subprocess.call([sys.executable,gmerge,'-o','C:\\r.tif','-of','GTiff','D:\\*.tif'],shell=True)

I did not know how to input the input files. Any idea is welcomed.

1

you can loop on your files and append them to your list

command = [sys.executable,gmerge,'-o','C:\\r.tif','-of','GTiff']

images = glob.glob("D:\\*.tif")
for image in images:
    command.append(image)

subprocess.call(command)
  • No need to loop. This will work as well subprocess.call(command+images) – user2856 Jul 10 '14 at 10:04

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.