logo资料库

ARCGIS中Python实现批量裁剪.docx

第1页 / 共1页
资料共1页,全文预览结束
程序代码: [python] view plaincopyprint? 1. import arcpy 2. arcpy.CheckOutExtension("spatial") 3. arcpy.gp.overwriteOutput=1 4. arcpy.env.workspace = "F:\\Modis_16\\1Moasic" 5. rasters = arcpy.ListRasters("*", "tif") 6. mask= "F:\\Vegetation Change\\Data\\Bound\\bound_Buffer_Polygon.shp" 7. for raster in rasters: 8. 9. print(raster) out= "F:\\Vegetation Change\\Data\\GIMMS Data\\new\\"+"ma_"+raster[0:8] arcpy.gp.ExtractByMask_sa(raster, mask, out) print("ma_"+raster[0:8]+" has done") 10. 11. 12. print("All done") 二、注意事项: 1.arcpy.gp.overwriteOutput=1 即覆盖之前的文件; 2.输入的是.tif 文件,输出的是 Grid 文件; 3.raster[0:8]表示从第 0 个开始取 8 个字符串; 4.bound_Buffer_Plygon.shp 后缀名不可或缺。 三、运行情况:
分享到:
收藏