GeoEnrich enriches input polygons with demographic variables describing the people and places contained within those polygons.

GeoEnrich workflow

A typical workflow involves first inspecting the available variables using the GeoEnrichVariables tool, once the appropriate variables have been identified, running the GeoEnrich tool with the selected variables.

Usage notes

  • The input DataFrame must include exactly one polygon column.
  • The polygons must have defined spatial reference.
  • You can use a wildcard in .setVariables() to retrieve multiple variables at once. See examples below for wildcard usage patterns.
  • Input polygons that are out of the spatial extent of the GeoEnrichment dataset will return NULL on all selected variables.
  • The GeoEnrichment dataset must be accessible to all Spark cluster nodes. You can either copy the dataset to a node-local directory accessible to Spark, or use SparkContext.addFile to distribute files to Spark working directories. For environment-specific setup guidance, see GeoEnrichment dataset setup.

Limitations

  • GeoEnrich currently supports only Esri-provided datasets. User-provided datasets are not supported.
  • Each ArcGIS GeoAnalytics Engine release is validated against its corresponding starter pack dataset version. Compatibility with earlier or later GeoEnrich Essentials dataset versions is not guaranteed.
  • GeoEnrich in GeoAnalytics Engine only supports returning values using each variable's default calculation method (for example, ACSAGEPF will return the count of 2023 Female Populations (ACS 5-Yr). ACSMEDHINC will return the median of household income).

Results

The output is the input DataFrame with one additional column for each selected GeoEnrichment variable.

Performance notes

  • Use only the variables required for your analysis to reduce processing overhead and output width.

Syntax

For more details, go to the GeoAnalytics Engine API reference for GeoEnrich.

Setter (Python)Setter (Scala)DescriptionRequired
run(dataframe)run(input)Runs the GeoEnrich tool using the input DataFrame.Yes
setDataPath(path)setDataPath(dataPath)Sets the path to the dataset used by GeoEnrich. The dataset must be accessible on all Spark cluster nodes.Yes
setVariables(*variables)setVariables(variables)Sets one or more GeoEnrichment variables to include in the output.Yes

Examples

Run GeoEnrich

PythonPythonScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# Imports
from geoanalytics.tools import GeoEnrich

usa_states_path = "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/" \
                  "services/USA_State_Boundaries/FeatureServer/0"

df = spark.read.format("feature-service").load(usa_states_path)

data_path = r"/data/GeoEnrich_Essentials_for_ArcGIS_GeoAnalytics_Engine.biz"

result = GeoEnrich() \
    .setDataPath(data_path) \
    .setVariables("*AGEPF80") \
    .run(df)

result.select("STATE_NAME", "ACSAGEPF80", "MOEAGEPF80", "RELAGEPF80").sort("STATE_NAME").show(5)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
+----------+----------+----------+----------+
|STATE_NAME|ACSAGEPF80|MOEAGEPF80|RELAGEPF80|
+----------+----------+----------+----------+
|   Alabama|     61144|      1948|       1.0|
|    Alaska|      4133|       422|       1.0|
|   Arizona|     87580|      2275|       1.0|
|  Arkansas|     35845|      1398|       1.0|
|California|    382197|      4580|       1.0|
+----------+----------+----------+----------+
only showing top 5 rows

Plot results

PythonPythonScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# Imports
from geoanalytics.tools import GeoEnrich

usa_states_path = "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/" \
                  "services/USA_State_Boundaries/FeatureServer/0"

df = spark.read.format("feature-service").load(usa_states_path)

data_path = r"/data/GeoEnrich_Essentials_for_ArcGIS_GeoAnalytics_Engine.biz"

result = GeoEnrich() \
    .setDataPath(data_path) \
    .setVariables("*AGEPF80") \
    .run(df)

result.select("STATE_NAME", "ACSAGEPF80", "MOEAGEPF80", "RELAGEPF80").sort("STATE_NAME").show(5)
Python
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11

# Plot the GeoEnrich results
result_plot = result.st.plot(cmap_values="ACSAGEPF80",
                             legend=True,
                             cmap="YlOrRd",
                             figsize=(16,8),
                             basemap="light",
                             show_axis=True)
result_plot.set_title("Female Population Aged 80–84 by U.S. State (2023 ACS 5-Year Estimates)")
result_plot.set_xlabel("X (Meters)")
result_plot.set_ylabel("Y (Meters)");
Plotting example for a GeoEnrichment result.

Version table

ReleaseNotes

2.1.0

Python tool introduced

2.1.0

Scala tool introduced

What's next?

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