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 SF
  3. Click Save > Save As > Save Map 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 top bar click Analysis > Summarize data > Aggregate Points.

  2. Set the following parameters:

    • 1. Graffiti cases within San Francisco.
    • 2. Census blocks in three neighborhoods SF.
    • Uncheck Keep areas with no points.
  3. Set the Result layer name to: Graffiti incidents within census blocks.

  4. Click Show credits. The analysis will consume approximately USD $2.10 (21 credits).

  5. Click Run Analysis.

  6. 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 > Change Style.

  2. In Counts and Amounts (Color), click Options.

  3. Click Symbols to select a blue to purple color ramp. Click OK when done.

  4. Check Classify Data. Select Natural breaks.

    Natural breaks
  5. Click OK > Done.

  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 incidents 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 are 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 top bar click Analysis > Summarize Data > Summarize Center and Dispersion.

  2. Set the following parameters:

    • 1. Graffiti incidents within San Francisco.
    • 2. Select Median Center and Ellipse. Keep the 1SD (one standard deviation) setting.
    • 3. None.
    • 4. Offensive/Non-Offensive
  3. Set the Result layer name to: Median centers of incidents by type.

  4. Click Show credits. The analysis will consume approximately USD $0.30 (3 credits).

  5. Click Run Analysis.

  6. 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 Median centers of incidents by type layer > Change style.

  2. Change Show location only to Type.

  3. Select Types (Unique symbols). If you want to change the style, click Options > Symbols and choose red for Offensive, orange for Non-Offensive, and gray for Other.

  4. When you are done changing the color scheme, click Ok > Ok > Done.

Style ellipses

  1. Select the Ellipse1SD layer > Change style.

  2. Change Show location only to Graffiti type.

  3. In Types (Unique symbols), click Options > Symbols.

  4. Click Fill. Set the Transparency to about 75%.

  5. Click Outline. Select an outline color that matches the color scheme you chose for the Median centers of incidents by type layer.

  6. Click Ok > Ok > Done.

  7. In the top bar click 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:

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