arcpy简单示例
最好在arcmap内置python模块运行。
这里用的是Zonel Stastic as Table模块,计算各个国家的逐月径流量的统计数据。需要对数百个tiff进行计算和导出,使用arcpy可以大大节省时间。
import arcpy import os from arcpy import env from arcpy.sa import * env.workspace = "D://ipy//" filelist= os.listdir('D:\\greenchrome\\jll\\jjl\\') inZoneData = "D:\\greenchrome\\World2018\\cntry00.shp" zoneField = "CNTRY_NAME" for name in filelist: inValueRaster = "D:\\greenchrome\\jll\\jjl\\"+name outTable = name[8:15]+".dbf" arcpy.CheckOutExtension("Spatial") outZSaT = ZonalStatisticsAsTable(inZoneData, zoneField, inValueRaster, outTable, "NODATA", "MEAN") print(name,'ok')