Data enrichment is the process of finding demographic data and local facts for locations around the world.
You can use thearcgis-rest-demographics package to access the ArcGIS GeoEnrichment service.
Steps
-
Install and reference the
arcgis-rest-demographicsandarcgis-rest-requestpackages. - Set an access token to authenticate the request.
- Define parameters to pass to the service.
- Call the service and handle the results.
Global data
You can access global data, also known as standard demographics, for 170 countries and regions. To get global data, you use data variables to find information about population, income, age, households, education, spending, jobs, marital status, and key facts.
Get global data
Learn how to return demographic information, such as total population, with the query method in ArcGIS REST JS.
import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { queryDemographicData } from "@esri/arcgis-rest-demographics";
const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);
queryDemographicData({
studyAreas: [{ geometry: { x: 0.1278, y: 51.5074 } }], // London
dataCollections: ["KeyGlobalFacts"],
authentication
}).then((response) => {
console.log(JSON.stringify(response, null, 2));
});Local data
You can use local data, also known as advanced demographics, to gain insight about specific countries, cities, or neighborhoods. Local data variables include information about housing, health, education, and more.
Get local data
Learn how to return market and purchasing trends with the query method in ArcGIS REST JS.
import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { queryDemographicData } from "@esri/arcgis-rest-demographics";
const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);
queryDemographicData({
studyAreas: [{ geometry: { x: -86.7679, y: 36.1745 } }], // Nashville, TN
analysisVariables: ["PsychographicsShopping.MP28067A_B", "transportation.X7027_I", "entertainment.X9005_I"],
authentication
}).then((response) => {
console.log(JSON.stringify(response, null, 2));
});