arcgis.geoenrichment module

The arcgis.geoenrichment module provides access to Business Analyst’s demographic and jurisdictional areas data through enrichment, standard geography queries and reporting. The source for analysis can be either local or remote. Using a local source requires ArcGIS Pro with the Business Analyst extension and at least one country’s data pack to be installed. A remote source requires access to a property configured Web GIS. A Web GIS can either be ArcGIS Online or an instance of ArcGIS Enterprise with Business Analyst.

Country

class arcgis.geoenrichment.Country(iso3, gis=None, year=None, **kwargs)

Enables access to data and methods for a specific country. This class can reference country data and methods available using data accessed through both a Web GIS and a local installation of ArcGIS Pro with the Business Analyst extension and local country data installed. Specifying this source is accomplished using the gis parameter when instantiating. If using the keyword Pro, Country will use ArcGIS Pro with Business Analyst and will error if the specified country is not available locally. Available countries can be discovered using get_countries().

property data_collections

Returns the supported data collections and analysis variables as a Pandas dataframe.

The dataframe is indexed by the data collection id(dataCollectionID) and contains columns for analysis variables(analysisVariable).

property dataset

Returns the currently used dataset for this country.json.

Note

This is only supported when using a Web GIS (ArcGIS Online or ArcGIS Enterprise as the gis source.

enrich(study_areas, enrich_variables=None, return_geometry=True, standard_geography_level=None, standard_geography_id_column=None, proximity_type=None, proximity_value=None, proximity_metric=None, output_spatial_reference=None, **kwargs)

Enrich provides access to a massive dataset describing exactly who people are in a geographic location. The most common way to delineate study_areas for enrichment is using polygons delineated areas, although points and lines can be used as well.

When points or lines are provided, an area surrounding the geometries is used for enrichment. This area can be defined using additional parameters, but by default is one kilometer around the geometry. Also, only straight-line distance is supported with line geometries, but points can use available transportation network methods [typically drive distance or drive time].

While already popular for site analysis, forecast modeling for a store or facility location, enrich provides access to a massive amount of data for any analysis of people and their relationship and interaction with the surrounding community, culture, economy and even the natural environment. Succinctly, enrich is how to access data for human geography analysis.

The study_areas for enrichment can be provided in a number of forms: a Spatially Enabled Pandas Data Frame or an Iterable my be provided. The iterable may be comprised of Geometry object instances or standard geography identifiers. While other values, such as string addresses or points-of-interest names may be provided, it is recommended to retrieve these locations in your workflow before performing enrichment.

Parameter

Description

study_areas

Required list, dictionary, FeatureSet or SpatiallyEnabledDataFrame containing the input areas to be enriched.

enrich_variables

Enrich variables can be specified using either a list of strings or the Pandas DataFrame returned from the enrich_variables() property. If using a list of strings, the values are mached against the enrich_variables() dataframe columns for name, ‘enrich_name’, or ‘enrich_field_name’. All the values must match to one of these columns.

return_geometry

Boolean indicating if the geometry needs to be returned in the output. The default is True.

standard_geography_level

If using a list of standard geography identifiers, the geography level must be specified here. This value is the level_name column retrieved in the levels() property.

standard_geography_id_column

If providing a Pandas DataFrame as input, and the DataFrame contains a column with standard geography identifiers you desire to use for specifying the input study_areas, please provide the name of the column as a string in this parameter.

proximity_type

If providing point geometries as input study_areas, you have the option to provide the method used to create the proximity around the point based on the available travel modes. These travel modes can be discovered using the travel_modes property. Valid values are from the name column in this returned DataFrame. Also, in addition to the transportation network travel modes, you also have the option of using straight_line, just using a straight line distance, a buffer, around the geometry. This is the default, and the only option if the geometry type is line.

proximity_value

This is the scalar value as either a decimal float or integer defining the size of the proximity zone around the source geometry to be used for enrichment. For instance, if desiring a five minute drive time, this value will be 5.

proximity_metric

This is the unit of measure defining the area to be used in defining the area surrounding geometries to use for enrichment. If interested in getting a five minute drive time, this value will be minutes.

output_spatial_reference

The default output will be WGS84 (WKID 4326). If a different output spatial reference is desired, please provide it here as a WKID or SpatialReference object instance.

hierarchy

The hierarchy of the datasets to use. The hierarchy is the “ID” that can be found in the hierarchies property. If none is provided, the default hierarchy will be used.

Returns

Pandas DataFrame with enriched data.

Here is an example of using ArcGIS Pro with Business Analyst and the United States data pack installed locally to enrich with a few key variables.

from arcgis.gis import GIS
from arcgis.geoenrichment import Country

# create country object instance to use local ArcGIS Pro + Business Analyst + USA data pack
usa = Country('usa', gis=GIS('pro'))

# select current year key enrichment variables for analysis
ev_df = usa.enrich_variables
kv_df = ev_df[
    (ev_df.data_collection.str.lower().str.contains('key'))  # key data collection
    & (ev_df.alias.str.lower().str.endswith('cy'))           # current year
]

# get data from ArcGIS Online to enrich as Spatially Enabled DataFrame
itm_id = '15d227c6da8d4b7baf713709ba3693ce'  # USA federal district court polygons
gis = GIS()  # anonymous connection to ArcGIS Online
aoi_df = gis.content.get(itm_id).layers[0].query().sdf

# enrich with variables selected above
enrich_df = usa.enrich(aoi_df, enrich_variables=kv_df)

Next, we can perform a similar workflow using ArcGIS Online instead of ArcGIS Pro by creating a couple of point geometries and using five-minute drive times around the locations.

import os

from arcgis.gis import GIS
from arcgis.geoenrichment import Country
from arcgis.geometry import Geometry
from dotenv import find_dotenv, load_dotenv

# load environment settings from .env file
load_dotenv(find_dotenv())

# create connection to ArcGIS Online organization using values saved in .env file
gis_agol = GIS(
    url=os.getenv('ESRI_GIS_URL'),
    username=os.getenv('ESRI_GIS_USERNAME'),
    password=os.getenv('ESRI_GIS_PASSWORD')
)

# create a country object instance
usa = Country('usa', gis=gis_agol)

# get just key variables for the current year
ev_df = usa.enrich_variables
kv_df = ev_df[
    (ev_df.data_collection.str.lower().str.contains('key'))  # key data collection
    & (ev_df.alias.str.lower().str.endswith('cy'))           # current year
]

# create a couple of point geometries on the fly for the example
coord_lst = [
    (-122.9074835, 47.0450249),  # Bayview Grocery Store
    (-122.8749600, 47.0464031)   # Ralph's Thriftway Grocery Store
]
geom_lst = [Geometry({'x': pt[0], 'y': pt[1], 'spatialReference': {'wkid': 4326}}) for pt in coord_lst]

# enrich the geometries and get a spatially enabled dataframe
enrich_df = usa.enrich(
    study_areas=geom_lst,
    enrich_variables=kv_df,
    proximity_type='driving_time',
    proximity_value=5,
    proxmity_metric='minutes'
)

Finally, we can also use standard geography identifiers to specify the study_areas as well.

import os

from arcgis.gis import GIS
from arcgis.geoenrichment import Country
from arcgis.geometry import Geometry
from dotenv import find_dotenv, load_dotenv

# load environment settings from .env file
load_dotenv(find_dotenv())

# create connection to ArcGIS Online organization using values saved in .env file
gis_agol = GIS(
    url=os.getenv('ESRI_GIS_URL'),
    username=os.getenv('ESRI_GIS_USERNAME'),
    password=os.getenv('ESRI_GIS_PASSWORD')
)

# create a country object instance
usa = Country('usa', gis=gis_agol)

# get just key variables for the current year
ev_df = usa.enrich_variables
kv_df = ev_df[
    (ev_df.data_collection.str.lower().str.contains('key'))  # key data collection
    & (ev_df.alias.str.lower().str.endswith('cy'))           # current year
]

# the block group ids for Olympia, WA
id_lst = ['530670101001', '530670101002', '530670101003', '530670101004', '530670102001', '530670102002',
          '530670102003', '530670103001', '530670103002', '530670103003', '530670103004', '530670104001',
          '530670104002', '530670104003', '530670105101', '530670105201', '530670105202', '530670105203',
          '530670105204', '530670106001', '530670106002', '530670106003', '530670106004', '530670106005',
          '530670107001', '530670107002', '530670107003', '530670108001', '530670108002', '530670109101',
          '530670109102', '530670109103', '530670110001', '530670111002', '530670112001', '530670113001',
          '530670116211', '530670117101', '530670117102', '530670117103', '530670120002', '530670122121',
          '530670122122', '530670122124', '530670111001', '530670121004']

# enrich the geometries and get a spatially enabled dataframe
enrich_df = usa.enrich(
    study_areas=geom_lst,
    enrich_variables=kv_df,
    standard_geography_level='block_groups'
)
property enrich_variables

Pandas Dataframe of available geoenrichment variables.

For instance, the following code, if run in Jupyter, will render the table below.

from arcgis.gis import GIS
from arcgis.geoenrichment import Country

usa = Country('usa', gis=GIS('pro'))

usa.enrich_variables.head()

name

alias

data_collection

enrich_name

enrich_field_name

0

CHILD_CY

2021 Child Population

AgeDependency

AgeDependency.CHILD_CY

AgeDependency_CHILD_CY

1

WORKAGE_CY

2021 Working-Age Population

AgeDependency

AgeDependency.WORKAGE_CY

AgeDependency_WORKAGE_CY

2

SENIOR_CY

2021 Senior Population

AgeDependency

AgeDependency.SENIOR_CY

AgeDependency_SENIOR_CY

3

CHLDDEP_CY

2021 Child Dependency Ratio

AgeDependency

AgeDependency.CHLDDEP_CY

AgeDependency_CHLDDEP_CY

4

AGEDEP_CY

2021 Age Dependency Ratio

AgeDependency

AgeDependency.AGEDEP_CY

AgeDependency_AGEDEP_CY

The values in this table can be useful for filtering to identify the variables you want to use for analysis and also for matching to existing datasets. This table, once filtered to variables of interest can be used as input directly into the enrich() method’s enrich_variables parameter.

Also, the enrich_field_name column in this table corresponds to the field naming convention used in output from the Enrich Layer tool in ArcGIS Pro. This enables you to, with a little scripting, identify variables used in previous analysis.

property geometry

Returns a Polygon object delineating the country’s area.

Note

Currently this is only supported when using a Web GIS (ArcGIS Online or ArcGIS Enterprise) as the gis source.

classmethod get(name, gis=None, year=None)

Get a reference to a particular country, given its name, or its two letter abbreviation or three letter ISO3 code.

Parameter

Description

name

Required string. The country name, two letter code or three letter ISO3 code identifying the country.

gis

Optional GIS instance. This specifies what GIS country sources are available based on the GIS source, a Web GIS (either ArcGIS Online or ArcGIS Enterprise) or ArcGIS Pro with the Business Analyst extension and at least one country data pack. If not explicitly specified, it tries to use an active GIS already created in the Python session. If an active GIS is not available, it then tries to use local resources, ArcGIS Pro with Business Analyst and at least one country dataset installed locally. Finally, if neither of these (Pro or an active GIS) are available, a GIS object instance must be explicitly provided.

year

Optional integer. Explicitly specifying the vintage (year) of data to use. This option is only available when using a ‘local’ GIS source, and will be ignored if used with a Web GIS source.

Returns

Country instance for the requested country.

property hierarchies

Return the available hierarchies and information for them as a dataframe.

property hierarchy

Get/Set the current hierarchy used. This will affect the enrichment variables

property levels

Returns levels of geography in this country, for the current dataset.

property properties

Returns namedtuple of relevant properties based on the gis source.

property reports

Returns the available reports for this country as a Pandas dataframe.

Note

Currently this is only supported when using a Web GIS (ArcGIS Online or ArcGIS Enterprise as the gis source.

search(query, layers=['*'])

Searches this country for places that have the specified query string in their name.

Returns a list of named areas matching the specified query

Parameter

Description

query

Required string. The query string to search for places within this country.

levels

Optional list of layer ids. Layer ids for a country can be queried using Country.levels properties.

Returns

A list of named areas that match the query string

Note

Currently this is only supported when using a Web GIS (ArcGIS Online or ArcGIS Enterprise as the gis source.

property subgeographies

Returns the named geographical places in this country, as NamedArea objects. Each named area has attributes for the supported subgeography levels within it, and the value of those attributes are dictionaries containing the named places within that level of geography. This allows for interactive selection of places using intellisense and a notation such as the following:

# Usage Example 1

usa = Country.get('USA')
usa.subgeographies.states['California'].counties['San_Bernardino_County']
# Usage Example 2

india.named_places.states['Bihar'].districts['Aurangabad'].subdistricts['Barun']

Note

Currently this is only supported when using a Web GIS (ArcGIS Online or ArcGIS Enterprise as the gis source.

property travel_modes

DataFrame of available travel modes for the country. This is determined by what transportation networks are available for the given country.

For instance, running the following code in Jupyter will return the table below.

from arcgis.gis import GIS
from arcgis.geoenrichment import Country

usa = Country('usa', gis=GIS('pro'))

usa.travel_modes

name

alias

description

type

impedance

impedance_category

time_attribute_name

distance_attribute_name

0

driving_time

Driving Time

Models the movement of cars…

AUTOMOBILE

TravelTime

temporal

TravelTime

Kilometers

1

driving_distance

Driving Distance

Models the movement of cars…

AUTOMOBILE

Kilometers

distance

TravelTime

Kilometers

2

trucking_time

Trucking Time

Models basic truck travel b…

TRUCK

TruckTravelTime

temporal

TruckTravelTime

Kilometers

3

trucking_distance

Trucking Distance

Models basic truck travel b…

TRUCK

Kilometers

distance

TruckTravelTime

Kilometers

4

walking_time

Walking Time

Follows paths and roads tha…

WALK

WalkTime

temporal

WalkTime

Kilometers

Note

The values in the name column are what is required for the proximity_type parameter for the enrich() method.

BufferStudyArea

class arcgis.geoenrichment.BufferStudyArea(area=None, radii=None, units=None, overlap=True, travel_mode=None)

BufferStudyArea allows you to buffer point and street address study areas.

Parameter

Description

area

Point object or street address (string) study area to be buffered

radii

List of distances by which to buffer the study area

Example: [1, 2, 3]

units

String, distance unit.

Example: Miles, Kilometers, Minutes (when using drive times/travel_mode)

overlap

Boolean. Uses overlapping rings when True, or non-overlapping disks when False

travel_mode

None or string, one of the supported travel modes when using network service areas.

To see a list of travel modes use the travel_modes property in the Country or Business Analyst class.

Example: Country.travel_modes[“alias”]

area

Alias for field number 0

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

overlap

Alias for field number 3

radii

Alias for field number 1

travel_mode

Alias for field number 4

units

Alias for field number 2

get_countries

arcgis.geoenrichment.get_countries(gis=None, as_df=True)

Retrieve available countries based on the GIS source being used.

Parameter

Description

gis

Optional GIS instance. This specifies what GIS country sources are available based on the Web GIS source, whether it be ArcGIS Online, ArcGIS Enterprise, or ArcGIS Pro with the Business Analyst extension and at least one country data pack. If not specified, it tries to use an active GIS already created in the Python session. If an active GIS is not available, it then tries to use local resourcea, ArcGIS Pro with Business and at least one country dataset installed locally. Finally, if neither of these sources are available, a GIS object must be explicitly provided.

as_df

Optional boolean, specifying if a Pandas DataFrame output is desired. If True, (the default) a Pandas DataFrame of available countries is returned. If False , a list of Country objects is returned.

Returns

Available countries as a list of Country objects, or a Pandas DataFrame of available countries.

create_report

arcgis.geoenrichment.create_report(study_areas, report=None, export_format='pdf', report_fields=None, options=None, return_type=None, use_data=None, in_sr=4326, out_name=None, out_folder=None, gis=None)

The Create Report method allows you to create many types of high quality reports for a variety of use cases describing the input area. If a point is used as a study area, the service will create a 1-mile ring buffer around the point to collect and append enrichment data. Optionally, you can create a buffer ring or drive-time service area around points of interest to generate PDF or Excel reports containing relevant information for the area on demographics, consumer spending, tapestry market, business or market potential.

Report options are available and can be used to describe and gain a better understanding about the market, customers / clients and competition associated with an area of interest.

Parameter

Description

study_areas

required list. Required parameter: Study areas may be defined by input points, polygons, administrative boundaries or addresses.

report

optional string. identify the id of the report. This may be one of the many default reports available along with our demographic data collections or a customized report. Custom report templates are stored in an ArcGIS Online organization as a Report Template item. The organization URL and a valid ArcGIS Online authentication token is required for security purposes to access these templates. If no report is specified, the default report is census profile for United States and a general demographic summary report for most countries.

export_format

Optional parameter to specify the format of the generated report. Supported formats include PDF and XLSX.

report_fields

Optional parameter specifies additional choices to customize reports. Below is an example of the position on the report header for each field.

options

Optional parameter to specify the properties for the study area buffer. For a full list of valid buffer properties values and further examples review the Input XY Locations’ options parameter.

By default a 1 mile radius buffer will be applied to point(s) and address locations to define a study area.

return_type

Optional parameter used for storing an output report item to Portal for ArcGIS instead of returning a report to a customer via binary stream. The attributes are used by Portal to determine where and how an item is stored. Parameter attributes include: user, folder, title, item_properties, URL, token, and referrer.

Example:

Creating a new output in a Portal for ArcGIS Instance: return_type = {

“user”: “testUser”, “folder”: “FolderName”, “title”: “Report Title”, “item_properties”: {…}, “url”: “https://hostname.domain.com/webadaptor”, “token”: “…”, “referrer”: “…”

}

use_data

Optional dictionary. This parameter explicitly specify the country or dataset to query. When all input features specified in the study_areas parameter describe locations or areas that lie in the same country or dataset, this parameter can be specified to provide an additional ‘performance hint’ to the service.

By default, the service will automatically determine the country or dataset that is associated with each location or area submitted in the study_areas parameter. Specifying a specific dataset or country through this parameter will potentially improve response time.

By default, the data apportionment method is determined by the size of the study area. Small study areas use block apportionment for higher accuracy whereas large study areas (100 miles or more) will use a cascading centroid apportionment method to maintain performance. This default behavior can be overridden by using the detailed_aggregation parameter.

in_sr

Optional parameter to define the input geometries in the study_areas parameter in a specified spatial reference system. When input points are defined in the study_areas parameter, this optional parameter can be specified to explicitly indicate the spatial reference system of the point features. The parameter value can be specified as the well-known ID describing the projected coordinate system or geographic coordinate system. The default is 4326

out_name

Optional string. Name of the output file [ending in .pdf or .xlsx)

out_folder

Optional string. Name of the save folder

enrich

arcgis.geoenrichment.enrich(study_areas, data_collections=None, analysis_variables=None, comparison_levels=None, add_derivative_variables=None, intersecting_geographies=None, return_geometry=True, gis=None, proximity_type=None, proximity_value=None, proximity_metric=None, sanitize_columns=True)

Enrich provides access to a massive dataset describing exactly who people are in a geographic location. The most common way to delineate study_areas for enrichment is using polygons delineated areas, although points and lines can be used as well.

When points or lines are provided, an area surrounding the geometries is used for enrichment. This area can be defined using additional parameters, but by default is one kilometer around the geometry. Also, only straight-line distance is supported with line geometries, but points can use available transportation network methods - typically drive distance or drive time.

While already popular for site analysis, forecast modeling for a store or facility location, enrich provides access to a massive amount of data for any analysis of people and their relationship and interaction with the surrounding community, culture, economy and even the natural environment. Succinctly, enrich is how to access data for human geography analysis.

Parameter

Description

study_areas

Required list, dictionary, FeatureSet or SpatiallyEnabledDataFrame containing the input areas to be enriched.

study_areas can be a Spatially Enabled DataFrame, FeatureSet or a lists of the following types:

  • addresses, points of interest, place names or other supported locations as strings.

  • dicts for multiple field addresses such as: Example: [{“address”: {“Address”:”380 New York St.”, “Postal”:”92373”, “CountryCode”:”USA”}}, {“address”: {“text”: “380 New York St Redlands CA 92373”}}]

  • Geometry instances

  • BufferStudyArea instances. By default, one-mile ring buffers are created around the points to collect and append enrichment data. You can use BufferStudyArea to change the ring buffer size or create network service areas around the points.

  • NamedArea instances to support standard geography. They are obtained using Country.subgeographies()/search().

    usa = Country("USA")
    ca_counties = usa.subgeographies.states['California'].counties
    
    # Pass as a dictionary
    counties_df = enrich(study_areas=ca_counties, data_collections=['Age'])
    counties_df
    

For more information and example see: https://developers.arcgis.com/python/guide/part2-where-to-enrich-study-areas/#enriching-study-areas

data_collections

Optional list. A Data Collection is a preassembled list of attributes that will be used to enrich the input features. Enrichment attributes can describe various types of information such as demographic characteristics and geographic context of the locations or areas submitted as input features in study_areas.

If none are specified then ‘KeyGlobalFacts’ is used. To see a list of the data collections available for a country you can use the Country class: Country.enrich_variables.data_collection.unique()

Note

Data Collections are case sensitive.

analysis_variables

Optional list. A Data Collection is a preassembled list of attributes that will be used to enrich the input features. With the analysis_variables parameter you can return a subset of variables enrichment attributes can describe various types of information such as demographic characteristics and geographic context of the locations or areas submitted as input features in study_areas.

add_derivative_variables

Optional list. This parameter is used to specify an array of string values that describe what derivative variables to include in the output. The list of accepted values includes: [‘percent’,’index’,’average’,’all’,’*’] * Deprecated *

comparison_levels

Optional list of layer IDs for which the intersecting study_areas should be geoenriched. * Deprecated *

intersecting_geographies

Optional parameter to explicitly define the geographic layers used to provide geographic context during the enrichment process. For example, you can use this optional parameter to return the U.S. county and ZIP Code that each input study area intersects. You can intersect input features defined in the study_areas parameter with standard geography layers that are provided by the GeoEnrichment class for each country. You can also intersect features from a publicly available feature service.

See intersecting_geographies for more details on formatting of this parameter. * Deprecated *

return_geometry

Optional boolean. A parameter to request the output geometries in the response.

gis

Optional GIS . If None, the GIS object will be used from the arcgis.env.active_gis. This GIS object must be authenticated and have the ability to consume credits

proximity_type

If the input study_areas are points, retrieving enriched variables requires delineating a zone around each point to use for apportioning demographic factors to each input geography. Default is straight_line, and if the input geometry is lines, straight_line is the only valid input.

proximity_value:

If the input study_areas are points or lines, this is the value used to create a zone around the points for apportioning demographic factors. For instance, if specifying five miles, this parameter value will be 5. Default is 1.

proximity_metric:

If the input study_areas are point or lines, this is the metric defining the proximity value. For instance, if specifying one kilometer, this value will be kilometers. Default is kilometers.

sanitize_columns

Optional boolean. Convert output column names to snake case python style. Default is True. Examples: Value is True: [‘source_country’, ‘area_type’, ‘aggregation_method’, ‘totpop’] Value is False: [‘sourceCountry’, ‘areaType’, ‘aggregationMethod’, ‘TOTPOP’]

Returns

Spatially Enabled DataFrame or Panda’s DataFrame with the requested variables for the study areas.

standard_geography_query

arcgis.geoenrichment.standard_geography_query(source_country=None, country_dataset=None, layers=None, ids=None, geoquery=None, return_sub_geography=False, sub_geography_layer=None, sub_geography_query=None, out_sr=4326, return_geometry=False, return_centroids=False, generalization_level=0, use_fuzzy_search=False, feature_limit=1000, as_featureset=False, gis=None)

This method allows you to search and query standard geography areas so that they can be used to obtain facts about the location using the enrich() method or create reports about.

GeoEnrichment uses the concept of a study area to define the location of the point or area that you want to enrich with additional information. Locations can also be passed as one or many named statistical areas. This form of a study area lets you define an area by the ID of a standard geographic statistical feature, such as a census or postal area. For example, to obtain enrichment information for a U.S. state, county or ZIP Code or a Canadian province or postal code, the Standard Geography Query helper method allows you to search and query standard geography areas so that they can be used in the GeoEnrichment method to obtain facts about the location. The most common workflow for this service is to find a FIPS (standard geography ID) for a geographic name. For example, you can use this service to find the FIPS for the county of San Diego which is 06073. You can then use this FIPS ID within the GeoEnrichment class study area definition to get geometry and optional demographic data for the county. This study area definition is passed as a parameter to the GeoEnrichment class to return data defined in the enrichment pack and optionally return geometry for the feature.

Parameter

Description

source_country

Optional string. to specify the source country for the search. Use this parameter to limit the search and query of standard geographic features to one country. This parameter supports both the two-digit and three-digit country codes illustrated in the coverage table.

country_dataset

Optional string. parameter to specify a specific dataset within a defined country.

layers

Optional list/string. Parameter specifies which standard geography layers are being queried or searched. If this parameter is not provided, all layers within the defined country will be queried.

ids

Optional parameter to specify which IDs for the standard geography layers are being queried or searched. You can use this parameter to return attributes and/or geometry for standard geographic areas for administrative areas where you already know the ID, for example, if you know the Federal Information Processing Standard (FIPS) Codes for a U.S. state or county; or, in Canada, to return the geometry and attributes for a Forward Sortation Area (FSA). Example: Return the state of California where the layers parameter is set to layers=[‘US.States’] then set ids=[“06”]

geoquery

Optional string/list. This parameter specifies the text to query and search the standard geography layers specified. You can use this parameter to query and find standard geography features that meet an input term, for example, for a list of all the U.S. counties that contain the word “orange”. The geoquery parameter can be a string that contains one or more words.

return_sub_geography

Optional boolean. Use this optional parameter to return all the subgeographic areas that are within a parent geography. For example, you could return all the U.S. counties for a given U.S. state or you could return all the Canadian postal areas (FSAs) within a Census Metropolitan Area (city). When this parameter is set to true, the output features will be defined in the sub_geography_layer. The output geometries will be in the spatial reference system defined by out_sr.

sub_geography_layer

Optional string/list. Use this optional parameter to return all the subgeographic areas that are within a parent geography. For example, you could return all the U.S. counties within a given U.S. state or you could return all the Canadian postal areas (FSAs) within a Census Metropolitan Areas (city). When this parameter is set to true, the output features will be defined in the sub_geography_layer. The output geometries will be in the spatial reference system defined by out_sr.

sub_geography_query

Optional string.User this parameter to filter the results of the subgeography features that are returned by a search term. You can use this parameter to query and find subgeography features that meet an input term. This parameter is used to filter the list of subgeography features that are within a parent geography. For example, you may want a list of all the ZIP Codes that are within “San Diego County” and filter the results so that only ZIP Codes that start with “921” are included in the output response. The subgeography query is a string that contains one or more words.

out_sr

Optional integer Use this parameter to request the output geometries in a specified spatial reference system.

return_geometry

Optional boolean. Use this parameter to request the output geometries in the response. The return type will become a Spatial DataFrame instead of a Panda’s DataFrame.

return_centroids

Optional Boolean. Use this parameter to request the output geometry to return the center point for each feature.

generalization_level

Optional integer that specifies the level of generalization or detail in the area representations of the administrative boundary or standard geographic data layers. Values must be whole integers from 0 through 6, where 0 is most detailed and 6 is most generalized.

use_fuzzy_search

Optional Boolean parameter to define if text provided in the geoquery parameter should utilize fuzzy search logic. Fuzzy searches are based on the Levenshtein Distance or Edit Distance algorithm.

feature_limit

Optional integer value where you can limit the number of features that are returned from the geoquery.

as_featureset

Optional boolean. The default is False. If True, the result will be a FeatureSet object instead of a SpatailDataFrame or Pandas’ DataFrame.

gis

Optional GIS . If None, the GIS object will be used from the arcgis.env.active_gis. This GIS object must be authenticated and have the ability to consume credits

Returns

Spatial or Pandas Dataframe on success, FeatureSet, or dictionary on failure.

service_limits

arcgis.geoenrichment.service_limits(gis=None)

Returns a Pandas’ DataFrame describing limitations for each input parameter.

Returns

Pandas DataFrame

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