使用一个polygon矢量提取某个文件夹中所有的tif格式栅格数据
(要确保先安装好arcpy包)
import arcpy
arcpy.CheckOutExtension("spatial")
arcpy.gp.overwriteOutput=1
arcpy.env.workspace = "E:\data" #所有栅格影像所在文件夹
rasters = arcpy.ListRasters("*", "tif")
mask= "E:\data\bound.shp" #用于提取的矢量掩膜
for raster in rasters:
print(raster)
out= "E:\data\images\"+raster
arcpy.gp.ExtractByMask_sa(raster, mask, out)
print("OK")
2019-09-02 23:53:36