How to perform feature analysis

1. Prepare feature data

The preliminary step for most feature analyses is to prepare input feature data. The input data is the data that is analyzed during the operation. In most cases, you will want to perform an analysis with your own data, but you can also use existing data hosted in ArcGIS.

There are a number of ways you can prepare data for analysis, but the easiest way is to use ArcGIS software and tools such as ArcGIS Online, Map Viewer, and ArcGIS Pro. These tools provide an interactive way to find, import, and prepare data.

Regardless of the tools or APIs you use, the analysis service requires input data in the form of feature data. The feature data must be a collection of features where each feature has a geometry and a set of attributes. The geometry type and attribute fields must be the same for all features. The format of the feature data can be a hosted feature layer (URL) or a feature collection (JSON).

The input data for an analysis is not changed by the analysis service and is treated as read-only. The output data contains changes that were applied during the analysis.

How to prepare data

The different ways to find or create input data for feature analyses are listed below:

  1. Find existing data: You can use existing data sources hosted in ArcGIS as input for analyses. The data sources need to be in the format of a hosted feature layer or table. For example, you can use hosted feature layers such as USA census block groups or World Demographics.

Below is a list of resources that you can use to search for input data for analyses:

To learn how to find data with these tools, go to the Find data sources tutorial.

  1. Import data as a feature layer: If you have existing point, line, or polygon data with attributes, you can use the portal to import the data and create your own hosted feature layers for analyses. You can import different formats such as CSV, XLS, shapefile, or GeoJSON. Once your data is hosted, the feature layer can be used as input for feature analysis using ArcGIS tools or APIs.

    To learn how to import data, go to the Create data sources tutorial.

  2. Feature collection (JSON): If you are programmatically accessing the spatial analysis service, you can also create a feature collection as a JSON structure and use it as input for the analysis.

    To learn how to format a feature collection, go to FeatureSet in Common data types.

  3. Enrich data: If you want to add demographic or local facts data attributes to an existing hosted feature layer such as USA census tracks, you can use the GeoEnrichment analysis.

    To learn how to enrich data, go to the Enrich data sources tutorial.

2. Select an operation

You can perform many different types of analyses with the feature analysis service. The operation you use depends on the type of data you have and the problem you want to solve. Use the table of categories below to help choose the correct operation. For more details about each, go to Types of feature analysis.

CategoryDescriptionOperations
Result
Example
Find dataSelects a subset of features using a SQL or spatial query.FindExistingLocations, DeriveNewLocations, ExtractFeaturesA new feature collection or hosted feature layer. find existing locations
Finds existing polygons that match a SQL query.
Combine dataCombines or joins features from two or more feature datasets.Merge, Overlay, Join, DissolveA new feature collection or hosted feature layer. dissolve boundaries
Dissolves polygons from two input feature datasets.
Summarize dataAggregates or summarizes feature data and creates statistics.Aggregate points, Summarize nearby, Summarize within, Summarize center and dispersionA new feature collection or hosted feature layer. aggregate points
Aggregate points into polygons.
Analyze patternsIdentifies spatial patterns and relationships in feature data.Find hot spots, Find outliers, Find point clusters, Find similar locations, Calculate density, Interpolate pointsA new feature collection or hosted feature layer. find hot spots
Find hot spots based on attribute values
Calculate geometriesPerforms geometric calculations on existing features or can create new feature data.Create buffers, Create centroids, Generate tessellations,A new feature collection or hosted feature layer. create buffers
Generate and merge buffers around features.

3. Perform the analysis

ArcGIS tools and APIs for analysis

To perform feature analysis, you can use different ArcGIS software and tools and APIs. In many cases, it is helpful to start by using tools to perform analyses interactively. Using tools will help you learn about the different types of operations, the required parameters, and how changing the parameters affects the analysis and results.

Below is a list of the different tools and APIs you can use:

  1. ArcGIS software and tools: These are applications such as Map Viewer or ArcGIS Pro that you can use to perform analysis interactively, to experiment with different analyses and parameters, and to visualize the results. If you are new to ArcGIS, it is recommended to start with these tools. For documentation and tutorials, go to ArcGIS Online analysis and ArcGIS Pro Analytics.

  2. ArcGIS APIs: These are programming APIs such as ArcGIS API for Python or ArcGIS REST JS that you can use to access the spatial analysis service. Use these APIs to build custom applications.

  3. ArcGIS REST API: This is the API you use to directly access the spatial analysis service. Use the REST API to build custom applications that access the service with HTTP requests.

You can use different ArcGIS tools and APIs to perform a feature analysis. Regardless of the mechanism you use, they all require user authentication to make requests to the spatial analysis service and the transactions need to managed as job requests (long transactions).

Security and authentication

To access the spatial analysis service, you need to implement user authentication. If you are using applications such as the Map Viewer or ArcGIS Pro, they authenticate users when they sign in, and then make requests to the service with the user credentials when spatial analysis tools are used. If you are accessing the service programmatically, you need to implement a user authentication workflow. This typically involves using account credentials to get an access token and then making requests to the service. Learn more about user authentication and tokens in Security and authentication.

Job processing

All feature analysis requests to the spatial analysis service are job requests. Regardless of the tool or API you use, each analysis is a long transaction that needs to be executed, checked, and the results need to be retrieved by the application. Tools such as Map Viewer and ArcGIS Pro manage most of the transactions for you, but when using APIs you have to manage the transaction yourself. Learn about the steps required in the code examples below.

ArcGIS software and tools

You can use the Map Viewer and ArcGIS Pro to perform feature analysis interactively. The Map Viewer is a web application that allows you to perform mapping operations and execute different types of analyses. ArcGIS Pro is a desktop application that runs on Windows devices that you can also use to execute different types of analyses. Both applications store the results of an analysis in ArcGIS as a hosted feature layer and display the results after an analysis. They also make it easy to visually analyze and inspect the results of the analysis interactively.

The general steps to perform a feature analysis with the Map Viewer are:

  1. Go to the Map Viewer and login in with your ArcGIS Online account.
  2. Identify one or more hosted feature layers to be used as input data and add them to the map.
  3. Go to Analysis tools.
  4. Select a tool, set the parameters (with the input hosted feature layer), and execute the analysis.
  5. View the results on the map.

Learn more about how to perform spatial analysis with the Map Viewer in the Tutorials.

ArcGIS APIs

The easiest way to programmatically execute an analysis request to the spatial analysis service is to use the ArcGIS API for Python or the ArcGIS REST JS API. These APIs provide security and authentication classes and also simplify the process of executing and managing job requests.

The steps to use the Python API are:

  1. Import an operation from the arcgis.features.analysis library.
  2. Provide your username and password.
  3. Identify the input feature layer(s) and URL(s) for the analysis.
  4. Set the parameters and execute the analysis.
  5. Get the results and add them to a map.

Example

This example executes a hot spot analysis.

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
traffic_crashes = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Traffic_Crashes/FeatureServer/0"
fishnet = "fishnet"

results = find_hot_spots(
    analysis_layer=traffic_crashes,
    shape_type=fishnet,
    # Outputs results as a hosted feature layer.
    output_name="Hot spot analysis results",
)

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

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

ArcGIS REST API

To access the spatial analysis service directly, you need to get the URL from your organization and then execute a job request. You get the service URL by making a self request and then extracting the URL from helperServices. Once you have the URL you can execute a job request to perform the analysis.

The steps to access the service are:

  1. Get the spatial analysis service URL from your organization.
  2. Submit a job request to the service with the operation and parameters.
  3. Check the status to see when the job is complete.
  4. Get the results.

Example

This example shows how to execute a job request to perform a hot spot analysis.

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"
    }
  }
}

4. Display the results

After you perform an analysis, the most common step is to display the results in a map. The spatial analysis service returns styling information with the resulting hosted feature layer and feature collection (JSON), so client applications and APIs can easily display the results in a map.

Visualize the layer

If you are using the Map Viewer or ArcGIS Pro, the resulting hosted feature layer is automatically added to the map when an analysis is complete. A renderer is also automatically applied from the styling information so you can visualize the results.

If you are using ArcGIS APIs, most APIs will access the styling information automatically in the resulting hosted feature layer to draw the feature layer in a map. The APIs access the styling information stored in the Drawing Info field of the feature layer.

If you own the resulting feature layer from analyses, you can use the item page, Map Viewer, or ArcGIS Pro to override drawing information by saving new colors and symbols in the layer. Alternatively, you can override the colors and symbols on the client-side using an ArcGIS API.

To learn more about visualizing data, go to Visualization.

Access the hosted feature layer

The easiest way to display the results of an analysis is to get the URL for the hosted feature layer that is returned and then use the URL to add the layer to the map. ArcGIS applications and APIs will use the URL to access the feature data and drawing information to render the layer in the map.

To learn more about accessing feature layers, go to Data hosting.

The steps to display the layer are:

  1. Sign in to your portal.
  2. Find the resulting hosted feature layer that was created from your analysis.
  3. Get the URL.
  4. Add the layer to an application using an API.

Example

This example displays the results of a hot spot analysis on traffic data by accessing the hosted feature layer URL. The feature colors and symbols are rendered using the information stored in the Drawing Info field in the layer. To get the hosted feature layer URL and drawing information, go to the item page.

This example uses the following:

  • Item page:
  • Feature layer URL and drawing info:
    • URL: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Traffic_Crashes_Resulting_in_Injury_Hot_Spots/FeatureServer/0
Visualization showing the results of a hot spot analysis for traffic accidents.
ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for .NETArcGIS Maps SDK for KotlinArcGIS Maps SDK for SwiftArcGIS Maps SDK for JavaArcGIS Maps SDK for QtEsri LeafletMapLibre GL JSOpenLayers
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
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
    const analysisResultsLayer = new FeatureLayer({
      url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Traffic_Crashes_Resulting_in_Injury_Hot_Spots/FeatureServer/0"
    });

    const map = new Map({
      basemap: "arcgis/light-gray",
      layers: [analysisResultsLayer]
    });

    const view = new MapView({
      container: "viewDiv",
      map: map,
      center: [-122.440, 37.775],
      zoom: 12,
      constraints: {
        snapToZoom: false
      },
    });

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