Tutorial: Summarize data

Learn how to aggregate and summarize features from feature data.

Summarize data analyses: counts of reported graffiti and median center of reports by type.

A summarize analysis finds which features in a layer are near or within features in another layer. It also calculates statistics such as the number of features that are in or near another layer.

In this tutorial, you use the Aggregate Points and Summarize Center and Dispersion operations to find the areas with the most incident reports about graffiti in San Francisco. You can perform the combine analyses either in Map Viewer or programmatically using the ArcGIS Python, ArcGIS REST JS, and ArcGIS REST APIs.

The analyses include:

  • Counting the number of calls concerning graffiti by census blocks.
  • Finding the median centers for incidents grouped by reported offensive and non-offensive graffiti.

Prerequisites

Steps

Copy the web map

The tutorial web map contains predefined layers to use as the starting point for the analyses outlined in the steps below.

  1. Go to the Summarize data tutorial web map and click Sign in.

  2. Verify that you have the following layers by toggling the visibility on and off:

    • Graffiti cases within San Francisco
    • Census blocks in three neighborhoods
  3. Click Save and open > Save As to save a copy.

Count reported incidents of graffiti within census blocks

The Census blocks in three neighborhoods SF hosted feature layer displays the census blocks for the Inner Mission, Hayes Valley, and South of Market neighborhoods. The Graffiti cases within SF hosted layer contains approximately 5,700 features representing reports on various incidents of graffiti within the area. Use the Aggregate Points operation to find the census blocks with the highest count of reported incidents of graffiti.

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the Settings (light) toolbar, click Analysis > Tools > Aggregate Points.

  2. Set the following parameters:

    • Input features: Graffiti cases within San Francisco
    • Area type: Polygon layer
    • Summary polygon layer: Census blocks in three neighborhoods SF.
    • Uncheck Keep areas with no points.
    • Output name: Graffiti incidents within census blocks.
  3. Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.628 and ArcGIS Online is 6.285 credits.

  4. Click Run.

  5. Click on the census blocks to view the Count of Points attribute in the popup.

Style the census blocks

You can change the renderer style to make it easier to visualize which census blocks have the highest number of reported incidents.

  1. Select the Graffiti incidents within census blocks layer.

  2. In the Settings (light) toolbar, click Styles.

  3. In Counts and Amounts (Color), click Style options.

  4. Click Symbol style to select a blue to purple color ramp. Click Done, then close the Symbol style window.

  5. Check Classify Data. Select Natural breaks.

  6. Click Done twice to close the Styles pane.

  1. Implement user authentication to access the spatial analysis service.
  2. Define the parameters of the request.
  3. Execute the operation. Note: This is a long transaction managed with a job request.
  4. Handle the results.

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

from arcgis import GIS
from arcgis.features.analysis import aggregate_points

portal = GIS(username="<USERNAME>", password="<PASSWORD>")

census_blocks = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Census_blocks_in_three_neighborhoods_SF/FeatureServer/0"
graffiti = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Graffiti_cases_within_census_blocks/FeatureServer/0"

results = aggregate_points(
    polygon_layer=census_blocks,
    point_layer=graffiti,
    keep_boundaries_with_no_points=False,
)

result_features = results["aggregated_layer"].query()

print(
    f"aggregate points result layer contains {len(result_features.features)} new records"
)

# show results in notebook with the map widget
map_widget = portal.map()
map_widget.add_layer(result_features)
map_widget.zoom_to_layer(result_features)
map_widget

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
{
  "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"
    }
  }
}

Style the layer

To learn how to style a feature layer, go to Visualization.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
  "renderer": {
    "authoringInfo": {
      "type": "classedColor",
      "classificationMethod": "esriClassifyNaturalBreaks"
    },
    "type": "classBreaks",
    "field": "Point_Count",
    "minValue": 1,
    "classBreakInfos": [

The aggregated incidents within census blocks should look something like this.

Find the median centers of graffiti reports by type

The Graffiti cases within San Francisco layer is styled based on report type. To find the median center and ellipses of reports based on their type, use the Summarize Center and Dispersion operation. You use the median center and ellipses of reports because the data is not distributed evenly. Ellipses summarize the central tendency, dispersion, and directional trends of data sized for one standard deviation and will help contextualize the median centers.

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the Settings (light) toolbar, click Analysis > Tools > Summarize Center and Dispersion.

  2. Set the following parameters:

    • Input layer: Graffiti cases within San Francisco.
    • Summary types: Select Median Center and Ellipse. Keep 1 standard deviation for the Ellipse size.
    • Group by field: Offensive/NotOffensive
    • Output name: Median centers of incidents by type.
  3. Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.57 and ArcGIS Online is 5.711 credits.

  4. Click Run.

  5. Click on the resulting features and view the popup.

Style median centers

You can change the renderer style to make it easier to visualize the dispersion and center for the types of reports.

  1. Select the MedianCenterLayer from Median centers of incidents by type group layer.
  2. In the Settings (light) toolbar, select Styles.
  3. Click + Field and select the Offence field.
  4. Click Style options, and choose red for Offensive, orange for Non-Offensive an gray for Other.
  5. Click Done twice to close the style pane.

Style ellipses

  1. Select the EllipseLayer from Median centers of incidents by type group layer.
  2. In the Settings (light) toolbar, select Styles.
  3. Click + Field and select the Offensive/NotOffensive field.
  4. Under Types (unique symbols), select Style options.
  5. Set the Fill Color to No Color for each type.
  6. Set the Outline color for each type to match the color scheme you choose for the median centers above.
  7. Click Done twice to close the style pane.
  8. In the Contents (dark) toolbar, click Save and open > Save to save your work.
  1. Implement user authentication to access the spatial analysis service.
  2. Define the parameters of the request.
  3. Execute the operation. Note: This is a long transaction managed with a job request.
  4. Handle the results.

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from arcgis import GIS
from arcgis.features.analysis import summarize_center_and_dispersion

portal = GIS(username="<USERNAME>", password="<PASSWORD>")

graffiti = {
    "url": "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Graffiti_cases_within_census_blocks/FeatureServer/0",
}

results = summarize_center_and_dispersion(
    analysis_layer=graffiti,
    summarize_type=["MedianCenter", "Ellipse"],
    ellipse_size="1 standard deviation",
)

result_features = results["ellipse_result_layer"].query()

print(
    f"summarize result layer contains {len(result_features.features)} records"
)
# show results in notebook with the map widget
map_widget = portal.map()
map_widget.add_layer(result_features)
map_widget.zoom_to_layer(result_features)
map_widget

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
{
  "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"
    }
  }
}

Style the layer

To learn how to style a feature layer, go to Visualization.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
//Median
{
  "renderer": {
    "type": "uniqueValue",
    "field1": "Offence",
    "uniqueValueInfos": [
      {
        "value": "Not offensive",
        "symbol": {
          "color": [

The values of these features represent the median centers of the type of graffiti: offensive, non-offensive, or other. You should also see the ellipses that summarize the dispersion within one standard deviation for each category.

What's next?

You performed two types of summarize analyses. You aggregated points within census blocks and found the median centers of reported incidents categorized by the type of graffiti. Your web map should look something like this.

Learn how to use additional tools, APIs, and location services in these tutorials:

Find and extract data

Find data with attribute and spatial queries using find analysis operations.


Discover patterns in data

Find patterns and trends in data using spatial analysis operations.


Combine data

Overlay, join, and dissolve features using combine analysis operations.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.