Skip to main content
9 events
when toggle format what by license comment
Oct 24, 2023 at 6:39 answer added user30184 timeline score: 1
Oct 24, 2023 at 6:14 comment added Abhijit Biswas I have run the basic command in a shell. But I have to write in python. I am a beginner in GDAL. Can you help me write the full code. My task it that Merge TIFF files using GDAL. Scenario: Create a tool that takes a folder path as input, and merges all the .tif files within a folder into a single TIFF file using GDAL. Input Folder Location Output Merged TIFF file
Oct 24, 2023 at 5:34 comment added Dataform Have you tried to run the command directly in a shell? May be you get some output that can help you. You can also add -v to get more output.
Oct 24, 2023 at 4:29 comment added Abhijit Biswas The following code not worked. import subprocess import glob import os import shlex file_list = glob.glob(r"E:\Spekter\data\data\Task2*.tif") files_string = " ".join(file_list) output_path = r"E:\Spekter\Task2\output.tif" command = command = f'gdal_merge.py -o "{output_path}" -of gtiff {files_string}' print("Command:", command) os.system(command) if os.path.exists(output_path): print(f"Output file '{output_path}' created successfully.") else: print("Output file was not created. Check for errors and permissions."
Oct 23, 2023 at 18:34 comment added user30184 I would first try with a path that has no space in the name Task 2 -> Task2.
Oct 23, 2023 at 18:33 comment added Dataform There is a space in output file path. Try to quote the output argument: command = f'gdal_merge.py -o "{output_path}" -of gtiff {files_string}'
Oct 23, 2023 at 18:16 history edited Vince CC BY-SA 4.0
moved first paragraph to body; entitled; formatting
S Oct 23, 2023 at 18:08 review First questions
Oct 23, 2023 at 22:35
S Oct 23, 2023 at 18:08 history asked Abhijit Biswas CC BY-SA 4.0