What is a summarize within analysis?
A summarize within analysis is the process of finding areas (and portions of areas) that overlap between two feature datasets and calculating statistics for the features that overlap. To execute the analysis, use the spatial analysis service and the Summarize
operation.
Real-world examples of this analysis include the following:
- Calculating the total acreage of land-use type features within each polygon of a watershed feature layer.
- Summarizing the average value of vacant parcels with each city boundary polygon.
- Calculating the total mileage of roads by road type within each county polygon.
How summarize within works
The general steps to performing a summarize within analysis are as follows:
- Review the parameters for the
Summarize
operation.Within - Send a request to get the spatial analysis service URL.
- Execute a job request with the following URL and parameters:
- URL:
https
:// <YOUR _ANALYSIS _SERVICE >/arcgis/rest/services/tasks/ GP Server/ Summarize Within/submit Job - Parameters:
sum
: The polygon features. Features, or portions of features, in theWithin Layer summary
that fall within the boundaries of these polygons will be summarized.Layer summary
: The polygon features into which the input points will be aggregated.Layer output
: A string representing the name of the hosted feature layer to return with the results.Name
- URL:
- Check the status.
- Get the output layer results.
To see examples using ArcGIS API for Python, ArcGIS REST JS, and the ArcGIS REST API, go to Examples below.
URL Request
http://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/SummarizeWithin/submitJob?<parameters>
Required parameters
Name | Description | Examples |
---|---|---|
f | The format of the data returned. | f=json f=pjson |
token |
An access token (API key or OAuth 2.0) with the required Spatial Analysis > Feature analysis privilege. | token= |
sum | The polygon features. Features, or portions of features, in the summary that fall within the boundaries of these polygons will be summarized. | {"url" {"layer |
summary | Point, line, or polygon features that will be summarized for each polygon in the sum . | {"url" {"layer |
Key parameters
Name | Description | Examples |
---|---|---|
sum | A Boolean value that instructs the task to calculate statistics based on shape type of the summary , such as the count of points, the total length of lines, or the total area of polygons of the summary within each polygon in the sum . If the summary is lines or polygons, the count of features within each summary polygon is returned. | true | false |
shape | When summary contains polygons: Acres | Hectares | SquareMeters | SquareKilometers | SquareMiles | SquareYards | SquareFeet When summary contains lines: Meters | Kilometers | Feet | Yards | Miles | "shape |
output | A string representing the name of the hosted feature layer to return with the results. NOTE: If you do not include this parameter, the results are returned as a feature collection (JSON). | {"service |
Privileges
Example
Calculate the length of bike routes
In this example, the length (in miles) of bike routes is calculated within district polygons. the summary
value is the Bike routes hosted feature layer. The sum
value is the Maintenance Assessment District hosted layer containing of polygon features.
The sum
parameter calculates the count of the line features and the group
parameter provides the summarized length of the bike routes within each district.
APIs
sumWithinLayer = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Summarize_Within/FeatureServer/2"
summaryLayer = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Summarize_Within/FeatureServer/1"
results = summarize_within(
summary_layer=summaryLayer,
sum_within_layer=sumWithinLayer,
sum_shape=True,
shape_units="Miles",
group_by_field="ROUTE",
minority_majority=False,
# Outputs results as a hosted feature layer.
output_name="Summarize within results"
)
print(f"Summarize within result item created {results.itemid}")
Service requests
Request
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded
&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
{
"helperServices": {
// Other parameters
"analysis": {
"url": "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
},
"geoenrichment": {
"url": "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
}
}
}