Howto: 在Zonal Statistics工具中使用重叠的区
文章编号 : 39516
软件: ArcGIS - ArcEditor 9.3, 9.3.1, 10 ArcGIS - ArcInfo 9.3, 9.3.1, 10 ArcGIS - ArcView 9.3, 9.3.1, 10
操作系统: N/A
软件: ArcGIS - ArcEditor 9.3, 9.3.1, 10 ArcGIS - ArcInfo 9.3, 9.3.1, 10 ArcGIS - ArcView 9.3, 9.3.1, 10
操作系统: N/A
1 个回复
易智瑞技术支持
赞同来自:
当使用多边形要素作为Zonal Statistics工具的区时,该工具会将多边形要素栅格化。如果多边形要素存在的重叠,栅格化会导致数据丢失。
Zonal Statistics中的这一缺陷,可以通过使用python逐一处理单个要素来解决。
内容:
# 导入系统模块 import arcgisscripting, os # 创建Geoprocessor对象 gp = arcgisscripting.create(9.3) gp.OverWriteOutput = 1 # 检查许可 gp.CheckOutExtension("Spatial") #设置默认工作空间 gp.workspace = "C:/Data" # 设置变量 raster = "measurements.tif" inFC = "zone_features.shp" outTable = "zonal_stats.dbf" DBF_dir = "dbf" #folder for temp dbf outputs if not os.path.exists(DBF_dir): os.mkdir(DBF_dir) #循环处理要素 inRows = gp.searchcursor(inputFC) inRows.reset() inRow = inRows.next() while inRow: # Zone_ID is the assumed name of the zone field print "{0} is being processed".format(inRow.Zone_ID) lyr = "Zone {0}".format(inRow.Zone_ID) gp.MakeFeatureLayer_management(inFC, lyr, '"FID" = {0}'.format(inRow.FID)) tempTable = "{0}/DBF_{1}.dbf".format(DBF_dir, inRow.Test) gp.ZonalStatisticsAsTable_sa(lyr, "Zone_ID", raster, tempTable, "DATA") inRow = inRows.next() #设置临时DBF文件的存储路径 gp.workspace = DBF_dir TableList = gp.ListTables("*") #合并临时DBF文件 gp.Merge(TableList, outTable)
创建时间:2011-11-04
最近更新: 2012-01-20
【原文链接】
http://support.esrichina.com.c ... .html
要回复问题请先登录或注册