## Summary

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 calculates attribute field statistics about those features within the polygons.

The following are examples of scenarios using Summarize Within:

- Given watershed boundaries and land-use boundaries by land-use type, calculate total acreage of land-use type for each watershed.
- Given county parcels and city boundaries, summarize the average value of vacant parcels within each city boundary.
- Given counties and roads, summarize the total mileage of roads by road type within each county.

## Illustration

## Usage

You can think of Summarize Within as taking two layers, the input polygons and the input summary features, and stacking them on top of each other. After stacking these layers, you peer down through the stack and count the number of input summary features that fall within the input polygons. Not only can you count the number of features, you can calculate simple statistics about the attributes of the input summary features, such as sum, mean, minimum, maximum, and so on.

Summarize Within can calculate standard statistics and geographically weighted statistics. Standard statistics summarize the statistical values without any weighting. Weighted statistics calculate values using the geographically weighted values of the proportion of lines within a polygon, or proportion of polygons within a polygon. Weighted statistics do not apply to points within polygons.

At ArcGIS Enterprise10.6.1, you can optionally calculate a group using the Group By Field parameter.

This geoprocessing tool is powered by ArcGIS GeoAnalytics Server. Analysis is completed on your GeoAnalytics Server and results are stored in your content in ArcGIS Enterprise.

It is recommended that you use feature layers hosted on your ArcGIS Enterprise portal or use a big data file share data when running GeoAnalytics Tools in ArcGIS Pro. Other data sources may perform slowly when there are more than 1000 features.

Learn more about sharing data to your portal

Learn more about creating a big data file share through Server Manager

Similar analysis can also be completed using the following:

- The ArcGIS Pro geoprocessing tool Summarize Within in the Standard Feature Analysis toolbox.

## Syntax

SummarizeWithin_geoanalytics (summarized_layer, output_name, polygon_or_bin, bin_type, {bin_size}, {summary_polygons}, sum_shape, {shape_units}, {standard_summary_fields}, {weighted_summary_fields}, {data_store}, {group_by_field}, {add_minority_majority}, {add_percentages})

Parameter | Explanation | Data Type |

summarized_layer |
The point, line, or polygon features that will be summarized by either polygons or bins. | Feature Set |

output_name | The name of the output polygon feature service containing the intersecting geometries and attributes. | String |

polygon_or_bin | Specifies whether summarized_layer will be summarized by polygons or bins. - POLYGONS —The summarized layer will be aggregated into a polygon dataset.
- BINS —The summarized layer will be aggregated into square or hexagonal bins.
| String |

bin_type | Bin shape that will be generated to summarize features into. - SQUARE —bin_size represents the height of a square. This is the default.
- HEXAGON —bin_size represents the height between two parallel sides.
| String |

bin_size (Optional) | The distance interval that represents the bin size and units by which the input features will be summarized. | Linear Unit |

summary_polygons (Optional) | The polygons used to summarize the features in the input summarized layer. | Feature Set |

sum_shape | Calculates the length of lines or area of polygons within your summary layer (polygon or bin). The count of points, lines, and polygons intersecting your summary shape will always be included. - ADD_SUMMARY —Summary shape values will be calculated. This is the default.
- NO_SUMMARY —Summary shape values will not be calculated.
| Boolean |

shape_units (Optional) | The unit used to calculate shape summary attributes. If the input summary_layer is 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 —Meters
- KILOMETERS —Kilometers
- FEET —Feet
- YARDS —Yards
- MILES —Miles
- ACRES —Acres
- HECTARES —Hectares
- SQUARE_METERS —Square meters
- SQUARE_KILOMETERS —Square kilometers
- SQUARE_FEET —Square feet
- SQUARE_YARDS —Square yards
- SQUARE_MILES —Square miles
| String |

standard_summary_fields [standard_summary_fields,...] (Optional) | Statistics that will be calculated on specified fields. - COUNT —Calculates the number of nonnull values. It can be used on numeric fields or strings. The count of [null, 0, 2] is 2.
- SUM —The sum of numeric values in a field. The sum of [null, null, 3] is 3.
- MEAN —The mean of numeric values. The mean of [0, 2, null] is 1.
- MIN —The minimum value of a numeric field. The minimum of [0, 2, null] is 0.
- MAX —The maximum value of a numeric field. The maximum value of [0, 2, null] is 2.
- STDDEV —The standard deviation of a numeric field. The standard deviation of [1] is null. The standard deviation of [null, 1,1,1] is 1.
- VAR —The variance of a numeric field in a track. The variance of [1] is null. The variance of [null, 1, 1, 1] is 1.
- RANGE —The range of a numeric field. This is calculated as the minimum values subtracted form the maximum value. The range of [0, null, 1] is 1. The range of [null, 4] is 0.
- ANY —This is a sample string from a field of type string.
| Value Table |

weighted_summary_fields [weighted_summary_fields,...] (Optional) | Weighted statistics that will be calculated on specified fields. - COUNT —The count of each field multiplied by the proportion of the summarized layer within the polygons.
- SUM —The sum of weighted of values in each field, where the weight applied is the proportion of the summarized layer within the polygons.
- MEAN —The weighted mean of values in each field, where the weight applied is the proportion of the summarized layer within the polygons.
- MIN —The minimum of weighted values in each field, where the weight applied is the proportion of the summarized layer within the polygons.
- MAX —The maximum of weighted values in each field, where the weight applied is the proportion of the summarized layer within the polygons.
- RANGE —Finds the difference between MIN and MAX.
| Value Table |

data_store (Optional) | Specifies the ArcGIS Data Store where the output will be saved. The default is SPATIOTEMPORAL_DATA_STORE. All results stored to the SPATIOTEMPORAL_DATA_STORE will be stored in WGS84. Results stored in a RELATIONAL_DATA_STORE will maintain their coordinate system. - SPATIOTEMPORAL_DATA_STORE —Output will be stored in a spatiotemporal big data store. This is the default.
- RELATIONAL_DATA_STORE —Output will be stored in a relational data store.
| String |

group_by_field (Optional) | A field from the input summary features that will be used to calculate statistics for each unique attribute value. For example, suppose the input summary features contain point locations of businesses that store hazardous materials, and one of the fields is HazardClass containing codes that describe the type of hazardous material stored. To calculate summaries by each unique value of HazardClass, use it as the group by field. | Field |

add_minority_majority (Optional) | Specifies whether minority (least dominant) and majority (most dominant) attribute values for each group field within each boundary will be added. If they are, two new fields are added to the output layer prefixed with Majority_ and Minority_. This parameter only applies when using group_by_field. - NO_MIN_MAJ —Minority and majority fields will not be added. This is the default.
- ADD_MIN_MAJ —Minority and majority fields will be added.
| Boolean |

add_percentages (Optional) | Specifies whether percentage fields will be added. If they are, the percentage of each unique group value is calculated for each input polygon. This parameter only applies when using group_by_field. - NO_PERCENT —Percentage fields will not be added. This is the default.
- ADD_PERCENT —Percentage fields will be added.
| Boolean |

## Code sample

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

```
#-------------------------------------------------------------------------------
# Name: SummarizeWithin.py
# Description: Summarize river polylines by counties.
#
# Requirements: ArcGIS GeoAnalytics Server
# Import system modules
import arcpy
# Set local variables
summarizedLayer = "https://MyGeoAnalyticsMachine.domain.com/geoanalytics/rest/services/DataStoreCatalogs/bigDataFileShares_Water/BigDataCatalogServer/Rivers"
summaryPolys = "https://MyGeoAnalyticsMachine.domain.com/geoanalytics/rest/services/DataStoreCatalogs/bigDataFileShares_Boundaries/BigDataCatalogServer/Counties"
summaryStatistics = ["Width", "MEAN"]
weighedSummaryStatistics = ["DOC", "SUM"]
outFS = 'SummarizedRivers'
dataStore = "SPATIOTEMPORAL_DATA_STORE"
# Execute SummarizeWithin
arcpy.geoanalytics.SummarizeWithin(summarizedLayer, outFS, "POLYGON", None,
None, summaryPolys,"ADD_SUMMARY",
"KILOMETERS", summaryStatistics,
weightedSummaryStatistics, dataStore)
```

## Environments

- Output Coordinate System
The coordinate system that will be used for analysis. Analysis will be completed on the input coordinate system unless specified by this parameter. For GeoAnalytics Tools, final results will be stored in the spatiotemporal data store in WGS84.

## Licensing information

- ArcGIS Desktop Basic: Requires ArcGIS GeoAnalytics Server
- ArcGIS Desktop Standard: Requires ArcGIS GeoAnalytics Server
- ArcGIS Desktop Advanced: Requires ArcGIS GeoAnalytics Server