Enrich data

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. Go to Map Viewer and sign in with your ArcGIS Online account.
  2. In the top bar, click Add to select and add the hosted feature layers that you want to enrich.
  3. Click Analysis > Data Enrichment > Enrich Layer.
  4. In the dropdown, select the analysis layer to enrich.
  5. Click Select Variables to select the data variables you want and then click Apply.
  6. Specify a Result layer name > Run Analysis.
  7. View the results on the map.

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. Go to the Map Viewer and sign in with your ArcGIS Online account.
  2. In the top bar, click Add > Browse Living Atlas Layers and type the following: World Countries (Generalized).
  3. Select the layer > Add to Map.
  4. Ensure that the layer is checked and is visible on the map.
  5. In the top bar, click Analysis > Data Enrichment > Enrich Layer.
  6. Set the following parameters:
    • Choose layer to enrich with new data: World Countries (Generalized).
    • Click Select Variables > Population > Show all Population Variables > Key Demographic Indicators.
    • Select Total Population.
    • Click Apply.
  7. Set the Result layer name to: Enriched World Countries.
  8. Uncheck Use current map extent so that all features are included in the analysis.
  9. Click Show credits. The analysis will consume approximately USD $0.251 (2.51 credits).
  10. Click Run Analysis.
  1. Provide an ArcGIS Identity 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:

  • 2022 Average Home Value
  • 2022 Renter Occupied Housing Units
  • 2022 Average Household Income (Esri)

Steps

Steps to use the Map ViewerSteps to use ArcGIS Python, REST JS, and REST APIs
  1. Go to the Map Viewer and sign in with your ArcGIS Online account.
  2. In the search bar, type in New Orleans, LA.
  3. In the top bar, click Add > Browse Living Atlas Layers and type the following: USA Census Block Groups.
  4. Select the layer > Add to Map.
  5. Ensure that the layer is checked and is visible on the map.
  6. In the top bar, click Analysis > Data Enrichment > Enrich Layer.
  7. Set the following parameters:
    • Choose layer to enrich with new data: U.S. Census Block Groups.
    • Click Select Variables > Housing > Show all Housing Variables.
    • Select the following variables:
      • 2022 Average Home Value
      • 2022 Renter Occupied Housing Units
      • 2022 Average Household Income (Esri)
    • Click Apply.
    • Set the Result layer name to: NOLA enriched census blocks.
  8. Click Show credits. The analysis will consume approximately USD $2.90 (29 credits).
  9. Click Run Analysis.
  1. Provide an ArcGIS Identity 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:

  • 2022 Coffee: Average (average spending)
  • 2022 HH Spent $100-$149 in Average Week at Food Stores
  • 2022 Shopped at Costco Warehouse or Club Store Last 6 Mo
  • 2022 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 top bar, click Analysis > Manage Data > Generate Tessellations.
  2. Set the following parameters:
    • Choose shape: Hexagon
    • Define extent: Portland boundary.
    • Check Only keep intersecting tessellations.
    • Define bin size by specifying:
      • Select Distance.
      • Enter 1 and select Miles.
  3. Set the Result layer name to: Portland one mile hexbins.
  4. Click Show credits. The analysis will consume approximately USD $.0352 (.352 credits).
  5. Click Run Analysis.
  1. Provide an ArcGIS Identity 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 top bar, click Analysis > Data Enrichment > Enrich Layer.
  2. Set the following parameters:
    1. Choose layer to enrich with new data: Portland one mile hexbins.
    2. Click Select Variables.
    3. In the search box, enter and select the following variables:
      • 2022 Coffee: Average
      • 2022 HH Spent $100-$149 in Average Week at Food Stores
      • 2022 Shopped at Costco Warehouse or Club Store Last 6 Mo.
      • 2022 Shopped at Walmart Neighborhood Market Grocery Store Last 6 Mo.
    4. Click Apply.
  3. Set the Result layer name to: Portland - Enriched hexbins.
  4. Click Show credits. The analysis will consume approximately USD $.0812 (8.12 credits).
  5. Click Run Analysis.
  1. Provide an ArcGIS Identity 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:

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