HOW TO
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.
The following code sample iterates through all the features from the input feature class and creates a report per feature.
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.
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
Get help from ArcGIS experts
Download the Esri Support App