Learn how to add demographic and local facts data to hosted feature layers using the Map Viewer, ArcGIS APIs, and the GeoEnrichment service.
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 Enrich
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:
-
Sign in to your portal:
- ArcGIS Location Platform: Go to https://location.arcgis.com > My portal.
- ArcGIS Online: Go to https://www.arcgis.com/home/signin.html.
- ArcGIS Enterprise: Learn more at ArcGIS Enterprise > Use > Get started > Access.
-
Go to Map Viewer.
-
In the Content (dark) toolbar, click Add to select and add the hosted feature layers that you want to enrich.
-
In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
-
For the Input features, select the analysis layer to enrich.
-
Click + Variable to select the data variables you want and then click Select.
-
Specify an Output name then click Run.
-
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
-
Sign in to your portal:
- ArcGIS Location Platform: Go to https://location.arcgis.com > My portal.
- ArcGIS Online: Go to https://www.arcgis.com/home/signin.html.
- ArcGIS Enterprise: Learn more at ArcGIS Enterprise > Use > Get started > Access.
- Go to the Map Viewer.
- In the Contents (dark) toolbar, click Add > Browse > Living Atlas and type the following:
World Countries Generalized
. - Select the layer > Add to Map.
- Ensure that the layer is visible on the map.
- In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
- Set the following parameters:
- Input features: World Countries Generalized.
- Enrichment variables > + Variable > Population.
- Select 2024 Total Population (Esri).
- Click Select.
- Set the Output name to:
Enriched World Countries
. - Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.251 and ArcGIS Online is 2.51 credits.
- Click Run.
-
Implement authentication with the following privileges:
- Spatial Analysis > Feature Analysis
-
Define the parameters.
-
Perform the operation.
Note: This is a long transaction managed with a job request.
-
Handle the results.
APIs
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
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded
&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
{
"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 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
-
Sign in to your portal:
- ArcGIS Location Platform: Go to https://location.arcgis.com > My portal.
- ArcGIS Online: Go to https://www.arcgis.com/home/signin.html.
- ArcGIS Enterprise: Learn more at ArcGIS Enterprise > Use > Get started > Access.
- Go to the Map Viewer.
- In the Contents (dark) toolbar, click Add > Browse layers and select Living Atlas from the dropdown and type the following:
US
.A Census Block Groups - Select the layer then click Add to Map.
- Ensure that the layer visible on the map.
- In the search bar, type in New Orleans, LA.
- In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
- 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:
NOL
.A enriched census blocks - Under Environment setting > Processing extent, choose Display extent.
- Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $2.84 and ArcGIS Online is 28.44 credits.
- Click Run.
-
Implement authentication with the following privileges:
- Spatial Analysis > Feature Analysis
-
Define the parameters.
-
Perform the operation.
Note: This is a long transaction managed with a job request.
-
Handle the results.
APIs
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
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded
&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
{
"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 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 H
H 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
- Go to the Enrich data tutorial web map and click Sign in.
- Verify that you the following layer by toggling the visibility on and off.
- Portland Boundary
- Click Save > Save As > Save Map to save a copy.
Part 2: Generate hexagon bins
- In the Settings (light) toolbar, click Analysis > Tools > Generate Tessellations.
- 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).
- Set the Output name to:
Portland one mile hexbins
. - Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.03 and ArcGIS Online is 0.3 credits.
- Click Run.
-
Implement authentication with the following privileges:
- Spatial Analysis > Feature Analysis
-
Define the parameters.
-
Perform the operation.
Note: This is a long transaction managed with a job request.
-
Handle the results.
APIs
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
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded
&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
{
"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.
Part 3: Enrich the hexagon bins
- In the Settings (light) toolbar, click Analysis > Tools > Enrich Layer.
- Set the following parameters:
- Input features: Portland one mile hexbins.
- Click + Variable.
- In the search box, enter and select the following variables:
2024 Coffee
2024 H
H 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
.
- Click Select.
- Set the Output name to:
Portland - Enriched hexbins
. - Click Estimate credits. The estimated cost for ArcGIS Location Platform is USD $0.08 and ArcGIS Online is 8.12 credits.
- Click Run.
-
Implement authentication with the following privileges:
- Spatial Analysis > Feature Analysis
-
Define the parameters.
-
Perform the operation.
Note: This is a long transaction managed with a job request.
-
Handle the results.
APIs
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
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded
&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
{
"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.
What's next?
Learn how to use additional tools, APIs, and location services in these tutorials:
Create data sources
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.