import os import rasterio from shapely.geometry import box def getAllFiles(filePath): fileList = [] # 设置要遍历的文件夹路径 folder_path = os.path.join(os.path.dirname(__file__), filePath) # 遍历文件夹 for root, dirs, files in os.walk(folder_path): for file in files: file_path = os.path.join(root, file) fileList.append(file_path) return fileList # allPath = getAllFiles('img/DDOM') def getTifEwkt(filePath): # 读取 tif 文件 with rasterio.open(filePath) as src: # 获取 tif 文件的边界框 (bounds) bounds = src.bounds # 使用 shapely 的 box 函数创建矩形几何对象 bbox = box(bounds.left, bounds.bottom, bounds.right, bounds.top) # 将矩形几何对象转换为 WKT 格式 wkt = bbox.wkt ewkt='SRID=4490;'+wkt print('矢量范围:'+wkt) return ewkt