HOW TO

Create and run Summary Reports per feature

Last Published: August 5, 2020

Summary

The Summary Reports geoprocessing tool can only create a report with a feature layer. Other than manually running the Summary Reports tool multiple times, the tool is not able create a report per feature.

Procedure

The following code sample iterates through all the features from the input feature class and creates a report per feature.

  1. Copy and paste the following Python script:
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")
Note:
Refer to Python in ArcGIS Pro for creating and running a script.
  1. Modify the script with the correct feature class name location. The field parameter, which is used for the selection query can also be modified to any other unique field.
Note:
The sample uses the report id to create and Infographic report per feature. The report id for the report can be found by running the Summary Reports geoprocessing tool and right-clicking and selecting the Copy Python command from the tool history.

Article ID: 000023930

Software:
  • ArcGIS Pro 2 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options