Discover patterns in data

Learn how to find patterns and trends in data from feature datasets using density, hot spot, and outlier analyses.

Parking enforcement incidents: hot spot, outlier, and density pattern analyses.

Analyze pattern analyses allow you to perform complex geometry, attribute, and statistic calculations to identify spatial patterns and relationships in feature data. All operations result in new feature data.

In this tutorial, you use the Calculate Density, Find Hot Spots, and Find Outliers operations in either Map Viewer or programmatically using the ArcGIS Python, ArcGIS REST JS, and ArcGIS REST APIs. The results identify areas where there are statistically higher occurrences of parking violations in San Francisco.

The analyses include:

  • Calculating the density of incidents per square mile.
  • Finding statistically significant hot and cold spots.
  • Finding statistically significant outliers in the data.

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 Analyze patterns in data tutorial web map and click Sign in.

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

    • Driveway and sidewalk parking incidents
    • SF Boundary
  3. Click Save > Save As > Save Map to save a copy.

Calculate density

There are 15,351 features in the Driveway and sidewalk parking incidents hosted feature layer that represent reported parking violations throughout San Francisco. Before performing a statistical analysis, it is helpful to understand how the features in the feature layer are distributed. Use the Calculate Density operation to determine where there are parking incidents on a scale of least to most dense per square mile.

To learn more, go to Calculate density.

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the top bar, click Analysis > Analyze Patterns > Calculate Density.

  2. Select the Driveway and sidewalk parking violations layer.

  3. Click Options and set the following parameters:

    • Clip output to: SF Boundary.
    • Classify by: Natural Breaks.
  4. Set the Result layer name to Calculate density of incidents.

  5. Click Show credits. The analysis will consume approximately USD $1.50 (15 credits)

  6. Click Run Analysis.

  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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

from arcgis import GIS
from arcgis.features.analysis import calculate_density

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

parking_citations = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Driveway_and_sidewalk_parking_violations/FeatureServer/0"

sf_boundary = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/SF_Boundary/FeatureServer/0"

results = calculate_density(
    input_layer=parking_citations,
    bounding_polygon_layer=sf_boundary,
    area_units="SquareMiles",
    classification_type="NaturalBreaks",
    num_classes=10,
    # output_name="<OUTPUT NAME>" if you want to save the results as a hosted feature layer.
)

result_features = results.query()

print(f"The density layer has {len(result_features.features)} new records")
map_widget = portal.map("San Francisco, CA")
map_widget.add_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"
    }
  }
}

The analysis identified at least six areas where there is a higher density of parking violations within the limits of San Francisco (excluding Treasure Island and Yerba Buena Island).

Find hot spots

The Find Hot Spots (Gi* de Getis-Ord) analysis determines if there are any statistically significant clusters in the data. For a feature to be in a hot spot cluster, it must have a high value (in this instance a high number of parking violations) and be surrounded by other clusters with high values. For a feature to be in a cold spot cluster, the feature must have a low value and be surrounded by other clusters with low values.

To learn more, go to Find hot spots.

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the navigation, click Analysis > Analyze Patterns > Find Hot Spots.

  2. Set the following:

    • 1. Choose layer for which hot spots will be calculated: Driveway and sidewalk parking violations.
    • 2. Find clusters of high and low: Points.
    • 3. Count points within: Hexagon grid.
  3. Set the Result layer name to Parking violation hot spots.

  4. Click Show credits. The analysis will consume approximately USD $1.50 (15 credits).

  5. Click Run Analysis.

  6. In the map, click on some hexagons to view the Number of Points and Statistical Significance in the popup.

  7. Compare the results of the hot spot analysis to the Calculate density of incidents layer.

  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
Expand
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
from arcgis import GIS
from arcgis.features.analysis import find_hot_spots

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

traffic_citations = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Driveway_and_sidewalk_parking_violations/FeatureServer/0"
hexagon = "hexagon"

results = find_hot_spots(
    analysis_layer=traffic_citations,
    shape_type=hexagon,
    output_name="Parking citation hot spots",
)

result_features = results.layers[0].query()

print(f"The hot spot layer has {len(result_features.features)} new records")

map_widget = portal.map("San Francisco, CA")
map_widget.add_layer(results)
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"
    }
  }
}

In the results, the red hexagons represent clusters that are hot spots with a statistically high number of reported incidents and are surrounded by other clusters with a statistically high number of incidents. The blue hexagons represent clusters that are cold spots with a low number of incidents and are surrounded by other clusters with a low number of incidents.

Find outliers

The Find outliers (Anselin local Moran's I) analysis identifies both clusters and anomalous values (outliers). It determines whether the attribute value for each feature is significantly different, defined as the resultant z-score and p-value, from its neighbors. It will classify the feature as: High-High (a high value surrounded by other high values), High-Low (a high value surrounded by low values), Low-High (a low value surrounded by high values), and Low-Low (a low value surrounded by other low values). A feature is part of a cluster when it has a similar value with its neighbors. A feature is considered an outlier when it has dissimilar values from its neighbors.

To learn more, go to Find outliers.

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the top bar, click Analysis > Analyze Patterns > Find Outliers.

  2. Set the following:

    • 1. Choose the layer from which to calculate outliers: Driveway and sidewalk parking violations.
    • 2. Find outliers of: Point counts.
    • 3. Count points within: Hexagon Grid
  3. Set the Result layer name to Parking violation outliers.

  4. Click Show credits. The analysis will consume approximately USD $1.50 (15 credits).

  5. Click Run Analysis.

  6. In the map, click on some hexagons to view the Number of Points and Cluster/Outlier Type in the popup.

  7. Compare the results of the analysis with the Calculate density of incidents and Parking violation hot spots layers.

  8. In the top bar click Save to save your web map.

  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
Expand
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
from arcgis import GIS
from arcgis.features.analysis import find_outliers

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

traffic_citations = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Driveway_and_sidewalk_parking_violations/FeatureServer/0"

results = find_outliers(
    analysis_layer=traffic_citations,
    shape_type="hexagon",
    output_name="Parking citation outliers"
)

result_features = results["outliers_result_layer"].layers[0].query()

print(
    f"The find outliers layer has {len(result_features.features)} new records"
)
map_widget = portal.map("San Francisco, CA")
map_widget.add_layer(results)
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"
    }
  }
}

The results show where there are anomalous values. Dark blue indicates significantly lower rates of parking violations as compared to its neighbors. Red indicates a higher rate of parking violations as compared to its neighbors.

What's next?

You have completed three different types of pattern analyses by calculating the density, finding hot spots, and finding the outliers of parking violations in San Francisco. Your 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.