Python+GDAL实现批量进行遥感图像的拼接

tech2025-11-10  6

主要的方法就是GDAL作者提供的gdal_merge.py,通过python调用控制台实现。

(python)

#如果图片大于4G,需要在输入图片路径前加入 -co BIGTIFF=YES import subprocess import os create_slope = '''D:/python/python.exe D:/python/Scripts/gdal_merge.py -of GTiff -o ''' list=[] fileDir = 'E:/湖北影像/武汉/2018' filepath = os.listdir(fileDir) for f in filepath: s = (fileDir+ "/"+f) list.append(s) print(list) tarDir = r'E:\湖北影像\武汉' filename = ' '.join(list) print(filename) subprocess.call(create_slope+r'E:\湖北影像\武汉\wuhan20181012-8432.tif'+' '+'-co COMPRESS=LZW '+filename)

报错的时候注意上面的注释。还可以加一些参数优化这个过程,详细请参考官方文档。

最新回复(0)