123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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)
- if file_path.endswith('.tif'):
- fileList.append(file_path)
- return fileList
- def getDirList(filePath,startName):
- dirList = []
-
- folder_path = os.path.join(os.path.dirname(__file__), filePath)
-
- for root, dirs, files in os.walk(folder_path):
- for dir in dirs:
- if dir.startswith(startName):
- dirList.append(filePath+'/'+dir)
- return dirList
- def getTifEwkt(filePath):
-
- with rasterio.open(filePath) as src:
-
- bounds = src.bounds
-
- bbox = box(bounds.left, bounds.bottom, bounds.right, bounds.top)
-
- wkt = bbox.wkt
- ewkt='SRID=4490;'+wkt
- print('矢量范围:'+wkt)
- return ewkt
|