Summarize Within

Title  Summarize Within

Summary

Geoprocessing tool that overlays a polygon layer with another layer to summarize the number of points, length of the lines, or area of the polygons within each polygon, and calculate attribute field statistics about those features within the polygons.


Illustration

Summarize Within

Usage


Syntax

Parameter Explanation
in_polygons

The polygons used to summarize the features, or portions of features, in the input summary layer.

in_sum_features

The point, line, or polygon features that will be summarized for each polygon in the input polygons.

out_feature_class (Optional)

The output polygon feature class containing the same geometries and attributes as the input polygons with additional new attributes about the number points, length of lines, and area of polygons inside each input polygon and statistics about those features.

keep_all_polygons (Optional)

Determines if all input polygons or only those intersecting or containing at least one input summary feature will be copied to the output feature class.Checked—All input polygons will be copied to the output feature class. This is the default.Unchecked—Only input polygons that intersect or contain at least one input summary feature will be copied to the output feature class.

shape_unit (Optional)

The unit in which to calculate shape summary attributes. If the input summary features are points no shape unit is necessary, since only the count of points within each input polygon is added.If the input summary features are lines, specify a linear unit. If the input summary features are polygons, specify an areal unit.Meters—MetersKilometers—KilometersFeet—FeetYards—YardsMiles—MilesAcres—AcresHectares—HectaresSquare meters—Square metersSquare kilometers—Square kilometersSquare feet—Square feetSquare yards—Square yardsSquare miles—Square miles

group_field (Optional)

Attribute field from the input summary features that is used for grouping. Features that have the same group field value will be combined and summarized with other features with the same group field value.When you chose a group field, an additional output grouped table will be created and its location must be specified. This output grouped table is required when using a group field.

esri_out_feature_service_name (Optional)

The name of the optional feature service to create on the federated server containing the result of this tool. If no name is specified an output feature service will not be created.

Code Samples

SummarizeWithin example 1 (Python window)

The following Python window script demonstrates how to use the SummarizeWithin function.


import arcpy
arcpy.env.workspace = 'C:/data/city.gdb'
arcpy.SummarizeWithin_analysis('neighborhoods', 'crimes', 'neighborhood_crimes')

                    

SummarizeWithin example 2 (stand-alone script)

The following standalone script is an example of how to use the SummarizeWithin function in a scripting environment.


# Description: Use SummarizeWithin to summarize the crimes in each city neighborhood

# import system modules 
import arcpy

# Set environment settings
arcpy.env.workspace = 'C:/data/city.gdb'

#  Set local variables
polys = 'neighborhoods'
points = 'crimes'
outFeatureClass = 'crimes_aggregated'
keepAll = 'KEEP_ALL'
sumFields = [['Damages', 'SUM'], ['VICTIM_AGE', 'MEAN']]
addShapeSum = 'ADD_SHAPE_SUM'
groupField = 'Crime_type'
addMinMaj = 'ADD_MIN_MAJ'
addPercents = 'ADD_PERCENT'
outTable = 'crimes_aggregated_groups'

arcpy.SummarizeWithin_analysis(polys, points, outFeatureClass, keepAll, 
                               sumFields, addShapeSum, '', groupField, 
                               addMinMaj, addPercents, outTable)
                    

Tags

Credits

Use limitations