How to get enrichment data

1. Define a study area

The first step it to define one or more study areas. A study area is a location used for spatial analysis in the GeoEnrichment service. The studyAreas parameter is required to make a request to the service. When you submit a request, the service returns information for the study areas provided.

Types of study areas

The value of the studyAreas parameter can take many forms. It can include one or more point, line, or polygon geometries, administrative boundaries, street addresses, and drive time service areas. For points and addresses, the GeoEnrichment service calculates a buffer or service area in which to aggregate data. See the examples below:

Study areaDescriptionExample
Named administrative boundariesIncludes countries, states, U.S. ZIP Codes, etcstudyAreas=[{"sourceCountry":"US","layer":"US.States","ids":["06"]}]
Street addressesDefaults to a one mile buffer around addressstudyAreas=[{"address":{"text":"380 New York St. Redlands, CA 92373"}}]
Buffer around a point or lineDefaults to a one mile buffer around point or linestudyAreas=[{"geometry":{"x":-117.1956,"y":34.0572}}]
Area within a polygonArea within a geometry defined by three or more points.studyAreas=[{"geometry":{"rings":[[[-117.185412,34.063170],[-122.81,37.81],[-117.200570,34.057196],[-117.185412,34.063170]]],"spatialReference":{"wkid":4326}}}]
Drive time service areasCalculates a drive time area around a point or addressstudyAreas=[{"geometry":{"x": -122.435, "y": 37.785},"areaType": "NetworkServiceArea","bufferUnits": "Hours","bufferRadii": [1],"travel_mode":"Driving"}]

2. Specify the data to find

To get data for a study area, you need to find the analysis variable and/or data collection names you need to use to get the data you want from the GeoEnrichment service. There are thousands of data variables and collections to choose from. You can query the service for these values or you can find them interactively with the Analysis Variable Finder and Data Collection Finder.

Analysis variables

An analysis variable is a parameter that represents data stored within the GeoEnrichment service. All valid enrich queries to the GeoEnrichment service return analysis variables in their response.

You can set the analysisVariables parameter of an enrich request to return global and local data for a study area.

Data collections

A data collection is a predefined list of analysis variables that can be used to get data from the GeoEnrichment service. When you make an enrich request with a data collection, the response contains information for each analysis variable in the collection.

For example, the KeyGlobalFacts data collection contains the following analysis variables:

  • Total Population (TOTPOP)
  • Total Households (TOTHH)
  • Average Household Size (AVGHHSZ)
  • Male Population (TOTMALES)
  • Female Population (TOTFEMALES)

3. Make a request

You can use ArcGIS REST JS, ArcGIS API for Python, or the ArcGIS REST API to access the service. Follow the steps below:

ArcGIS APIs

  1. Import the geoenrichment, GIS, Geometry, and pandas modules.
  2. Set your API key or OAuth 2.0 access token.
  3. Use the enrich method and set the following parameters:
    • study_areas: The study area in which you want the data returned.
    • analysis_variables or data_collections. If you provide neither parameter, data from the KeyGlobalFacts data collection will be returned by default.

Example

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
from arcgis.geoenrichment import *
from arcgis.geometry import Geometry
from arcgis.gis import GIS
import pandas as pd


def main():
    #authenticate with portal using API-KEY
    api_key = "YOUR_API_KEY"
    portal = GIS("https://www.arcgis.com", api_key=api_key)

    #create studyarea of point location
    pt = Geometry({"x":-74.0060,"y":40.7128})

    #create one-mile radii trade area
    buffered = BufferStudyArea(area=pt, radii=[1], units='Miles')

    #enrich using householdtotals data collection
    result_data_frame = enrich(study_areas=[buffered], data_collections=['educationalattainment'])

    #print entire data frame
    pd.set_option("display.max_rows", None)
    pd.set_option("display.max_colwidth", None)
    print(result_data_frame)

if __name__ == "__main__":
    main()

ArcGIS REST API

  1. Construct a GET or POST request.
  2. Set the following parameters:
    • studyAreas: The study area in which you want the data returned.
    • The analysisVariables or dataCollections. If you provide neither parameter, data from the KeyGlobalFacts data collection will be returned by default.
    • token: An API key or OAuth 2.0 access token.
  3. Send the request.

Example

This example returns data from the educationalattainment data collection in a 1-mile buffer around a point.

cURLcURLHTTP
Use dark colors for code blocksCopy
     
1
2
3
4
5
curl https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/Geoenrichment/enrich? \
-d "studyAreas=[{'geometry':{'x': -74.0060, 'y': 40.7128}}]" \
-d "dataCollections=[educationalattainment]" \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"

4. Use the results

After you retrieve the data from the service, the most common step is to display the data in a map.

Example

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS API for PythonArcGIS REST JSEsri 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
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
        function getDemographicData(point) {
          // Request demographic data
          arcgisRest.queryDemographicData({
              studyAreas: [{ "geometry": { "x": point.longitude, "y": point.latitude } }],
              authentication: authentication
            })
            .then((response) => {
              if (response.results[0].value.FeatureSet.length > 0 &&
                response.results[0].value.FeatureSet[0].features.length > 0) {
                const attributes = response.results[0].value.FeatureSet[0].features[0].attributes;
                showData(attributes, point);
              } else {
                console.log("No data found.");
              }
            });
        }
Expand

Tutorials

Services

GeoEnrichment service

Find facts and demographic information about a location or area.

API support

Full supportPartial supportNo support
  • 1. Access via ArcGIS REST JS or use a task.
  • 2. Access via HTTP request.
  • 3. Access via HTTP request and authentication.
  • 4. Access via ArcGIS REST JS.

Tools

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