import arcpy
from arcpy.sa import *
path = "G:/GEE/spartinaWater" # 工作路径
arcpy.env.workspace = path
rasters = arcpy.ListRasters("*0.tif", "tif")
arcpy.CheckOutExtension("Spatial")
inMaskDataAll = ["site4_20171231_20180931.tif"]
for inMaskData in inMaskDataAll: 由于我需要裁剪的不仅是 2 个掩模,所以用了两个 for 循环
for inRaster in rasters:
ractByMask = ExtractByMask(inRaster, inMaskData) # 裁剪的工具
ractByMask.save(path+'/'+str(inMaskData)[:5]+'_'+inRaster[:25]+'.tif')
print(inRaster)
2.下面是利用 Resample_management 批量进行重采样的工具
rasters = arcpy.ListRasters("site*", "tif")
for inRaster in rasters:
arcpy.Resample_management(inRaster, path+'/'+inRaster[:-4]+'_re.tif',
"20171002R2.tif", "CUBIC")