操作方法
汇总报告地理处理工具只能创建带有要素图层的报告。 除了多次手动运行汇总报告工具外,该工具无法为每种要素创建报告。
以下代码示例迭代输入要素类中的所有要素,并为每种要素创建报告。
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。
注: 示例使用报告 ID 创建每种要素的信息图表报告。 可以通过运行汇总报告地理处理工具并右键单击并从工具历史记录中选择复制 Python 命令来找到报告的报告 ID。
文章 ID: 000023930
获取来自 ArcGIS 专家的帮助
下载 Esri 支持应用程序
You can also download the app to access the chatbot anytime! Download it now.