Tutorial: Enrich data

Learn how to add demographic and local facts data to hosted feature layers using the Map Viewer, ArcGIS APIs, and the GeoEnrichment service.

Esri Tapestry Segmentation data for the United States

GeoEnrichment is the process of discovering and adding demographic and local facts data to feature data. To enrich data, you choose from thousands of data variables grouped into categories such as population, age, income, housing, and spending, and then use the Map Viewer, GeoEnrichment service, or spatial analysis service to enrich the data. The additional data can be used to reveal demographic, socioeconomic, and other financial and business-related patterns for a geographic area.

In this tutorial, you use the Map Viewer, ArcGIS API for Python, ArcGIS REST JS, and the ArcGIS REST API to add demographic information to hosted feature layers using the EnrichLayer operation from the spatial analysis service.

Prerequisites

Steps

The easiest way to enrich data is to use the Map Viewer. The main requirement is that you have a hosted feature layer available to perform the enrichment analysis.

The general steps to use the Map Viewer include the following:

  1. Sign in to your portal:

  2. Go to Map Viewer.

  3. In the Content (dark) toolbar, click Add to select and add the hosted feature layers that you want to enrich.

  4. In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.

  5. For the Input features, select the analysis layer to enrich.

  6. Click + Variable to select the data variables you want and then click Select.

  7. Specify an Output name then click Run.

  8. View the results on the map.

Code examples

The examples below show you how to enrich different types of hosted feature layers with different data variables. The analysis ranges from country to city scale.

Enrich countries with population data

In this example, you add population data to countries in the World Countries (Generalized) hosted feature layer. The data variable used is Total Population.

Steps

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. Sign in to your portal:

  2. Go to the Map Viewer.
  3. In the Contents (dark) toolbar, click Add > Browse > Living Atlas and type the following: World Countries Generalized.
  4. Select the layer > Add to Map.
  5. Ensure that the layer is visible on the map.
  6. In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
  7. Set the following parameters:
    • Input features: World Countries Generalized.
    • Enrichment variables > + Variable > Population.
    • Select 2024 Total Population (Esri).
    • Click Select.
  8. Set the Output name to: Enriched World Countries.
  9. Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.251 and ArcGIS Online is 2.51 credits.
  10. Click Run.
  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
inputLayer = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer/0"

results = enrich_layer(
    input_layer=inputLayer,
    analysis_variables=["KeyGlobalFacts.TOTPOP"],
    output_name="Enriched world countries",  # Outputs results as a hosted feature layer
)

print(f"New item created : {results.itemid}")
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"
    }
  }
}

Results

The results are returned in a new hosted feature layer containing 251 country boundary polygons enriched with population data.

Enrich layers analysis revealing the total population by country.

Enrich USA census blocks with housing data

In this example, you add housing and household data to the USA Census Block Groups hosted feature layer, provided by the ArcGIS Living Atlas of the World.

The data variables include the following:

  • 2024 Average Home Value (Esri)
  • 2020 Renter Occupied Housing Units (U.S. Census)
  • 2024 Average Household Income (Esri)

Steps

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. Sign in to your portal:

  2. Go to the Map Viewer.
  3. In the Contents (dark) toolbar, click Add > Browse layers and select Living Atlas from the dropdown and type the following: USA Census Block Groups.
  4. Select the layer then click Add to Map.
  5. Ensure that the layer visible on the map.
  6. In the search bar, type in New Orleans, LA.
  7. In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
  8. Set the following parameters:
    • Input features: U.S. Census Block Groups.
    • Under Enrichment data, Click + Variable > In the search box enter the following variable names and check each one to add it to the selected variables:
      • 2024 Average Home Value (Esri)
      • 2020 Renter Occupied Housing Units (U.S. Census)
      • 2024 Average Household Income (Esri)
    • Click Select.
    • Set the Result Layer > Output name to: NOLA enriched census blocks.
    • Under Environment setting > Processing extent, choose Display extent.
  9. Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $2.84 and ArcGIS Online is 28.44 credits.
  10. Click Run.
  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
inputLayer = "https://services2.arcgis.com/FiaPA4ga0iQKduv3/arcgis/rest/services/USA_Block_Groups_v1/FeatureServer/0"

results = enrich_layer(
    input_layer=inputLayer,
    analysis_variables=[
        "homevalue.AVGVAL_CY",
        "KeyUSFacts.RENTER_CY",
        "AtRisk.AVGHINC_CY",
    ],
    country="US",
    context={
        "extent": {
            "xmin": -10064584.78182423,
            "ymin": 3469864.993711926,
            "xmax": -10005269.647874909,
            "ymax": 3535218.6528957766,
            "spatialReference": {"wkid": 102100, "latestWkid": 3857},
        }
    },
    output_name="Enrich layers census block results",  # Outputs results as a hosted feature layer
)

print(f"New item created : {results.itemid}")
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"
    }
  }
}

Results

The results are returned in a new hosted feature layer containing census blocks enriched with the housing data.

Enrich layers analysis revealing home value, renter, and household income data.

Enrich tessellations with local business data

In this tutorial, you add local business data related to coffee consumers and spending within the Portland City Boundary hosted feature layer. This data could be used to find the areas best suited to support a new coffee bean roasting business.

To subdivide areas within the Portland City Boundary, you will create a hexagon bin tessellation. After creation, you will enrich the bins with coffee consumer and spending information. The data variables you will use are:

  • 2024 Coffee (average spending)
  • 2024 HH Spent $100-$149 in Average Week at Food Stores
  • 2024 Shopped at Costco Warehouse or Club Store Last 6 Mo
  • 2024 Shopped at Walmart Neighborhood Market Grocery Store Last 6 Mo

Steps

Part 1: Copy the web map
  1. Go to the Enrich data tutorial web map and click Sign in.
  2. Verify that you the following layer by toggling the visibility on and off.
    • Portland Boundary
  3. Click Save > Save As > Save Map to save a copy.
Part 2: Generate hexagon bins
Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the Settings (light) toolbar, click Analysis > Tools > Generate Tessellations.
  2. Set the following parameters:
    • Bin shape type: Hexagon
    • Bin size measurement: Area
    • Bin size: 1
    • Bin size units: Square Miles
    • Extent layer: Portland boundary.
    • Only keep intersecting tessellations: true (checked).
  3. Set the Output name to: Portland one mile hexbins.
  4. Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.03 and ArcGIS Online is 0.3 credits.
  5. Click Run.
  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
results = generate_tessellation(
    bin_size=1,
    bin_type="HEXAGON",
    bin_size_unit="Miles",
    intersect_study_area=True,
    extent_layer="https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Boundary/FeatureServer/0",
    # Outputs results as a hosted feature service.
    output_name="Generate tessellation results",
)
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 result is a new hosted feature layer that contains hexagon bins (polygons) for Portland.

Generate tessellations analysis showing one mile hexagon bins.
Part 3: Enrich the hexagon bins
Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
  2. Set the following parameters:
    1. Input features: Portland one mile hexbins.
    2. Click + Variable.
    3. In the search box, enter and select the following variables:
      • 2024 Coffee
      • 2024 HH Spent $100-$149 in Average Week at Food Stores
      • 2024 Shopped at Costco Warehouse or Club Store Last 6 Mo.
      • 2024 Shopped at Walmart Neighborhood Market Grocery Store Last 6 Mo.
    4. Click Select.
  3. Set the Output name to: Portland - Enriched hexbins.
  4. Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.08 and ArcGIS Online is 8.12 credits.
  5. Click Run.
  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
results = enrich_layer(
    input_layer="<Generate tessellations results URL>",
    analysis_variables=[
        "food.X1122_A",
        "GroceryAlcoholicBeverages.MP13002H_B",
        "GroceryAlcoholicBeverages.MP13026A_B",
        "GroceryAlcoholicBeverages.MP13030A_B",
    ],
    output_name="Enriched one mile hexbin results",  # Outputs results as a hosted feature layer
)

print(f"New item created : {results.itemid}")
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"
    }
  }
}

Results

The result is a new hosted feature layer containing 203 hexagons enriched with consumer spending data.

Enrich layers analysis visualizing consumer spending by data variable.

What's next?

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

Create data sources

Import, create, and generate data for feature analysis.


Find data sources

Discover data in ArcGIS that you can use for feature analysis.


Find and extract data

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


Combine data

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


Summarize data

Aggregate and summarize features using summarize analysis operations.


Discover patterns in data

Find patterns and trends in data using spatial analysis operations.


Perform a feature analysis

Perform a feature analysis using ArcGIS REST JS.


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