操作方法

如何为每种要素创建和运行汇总报告

Last Published: August 5, 2020

摘要

汇总报告地理处理工具只能创建带有要素图层的报告。 除了多次手动运行汇总报告工具外,该工具无法为每种要素创建报告。

过程

以下代码示例迭代输入要素类中的所有要素,并为每种要素创建报告。

  1. 复制并粘贴以下 Python 脚本:
import arcpy import os #Loop through all of the feature and select feature by county name #Create Infographic for each feature arcpy.env.baDataSource = "ONLINE;US;"                  #use online data source fc = "C:\Temp\MyProject\MyProject.gdb\ca_counties"     #input feature class field = "NAME"                                         #field for selection query cursor = arcpy.SearchCursor(fc) row = cursor.next() while row:     attrvalue = str(row.getValue(field))                        #search attribute value (string)     expression = field + "=" + "'" + attrvalue + "'"            #expression     LayerSelection = arcpy.management.SelectLayerByAttribute(fc, "NEW_SELECTION",  expression, None)  #selection     var=arcpy.ba.SummaryReports(LayerSelection, "e05dfbf89298414499782398d541c78d",                         r"C:\Temp\MyProject\SummaryReports",                         "INDIVIDUAL_FEATURES", "CREATE_REPORT_PER_TEMPLATE",                         "PDF", None, None, None, None, None, None, None, '',                         "Prepared By Code Sample")     splitfilename = os.path.splitext(var[0])     newfilename = splitfilename[0]+ "[" + attrvalue + "]" + splitfilename[1]     originalfile = str(var[0])     newfile = newfilename.replace("'", '', 2)     outputfile = originalfile.replace("'", '', 2)     print(newfile)     os.rename(outputfile, newfile)     row = cursor.next() print("Infographic reports completed")
注: 有关创建和运行脚本的信息,请参阅 ArcGIS Pro 中的 Python
  1. 用正确的要素类名称位置修改脚本。 用于选择查询的字段参数也可以修改为任何其他唯一字段。
注: 示例使用报告 ID 创建每种要素的信息图表报告。 可以通过运行汇总报告地理处理工具并右键单击并从工具历史记录中选择复制 Python 命令来找到报告的报告 ID。

文章 ID: 000023930

接收通知并查找新问题或常见问题的解决方案

从我们全新的 AI 聊天机器人中获得简明答案和视频解决方案。

下载 Esri 支持应用程序

相关信息

发现关于本主题的更多内容

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项
Esri Support AI Chatbot