Geocode Locations From Table (Geocoding)

Summary

Geocodes hosted tables using locators hosted on an ArcGIS Enterprise portal, which creates a hosted feature layer containing the geocoded results.

This tool automates the process of geocoding tables published to the portal and saves the output to the portal. If you do not need to save the geocode results to the portal, use the Geocode Table pane or the Geocode Addresses tool.

Note:

You must have publisher or administrator privileges on the portal to run this tool. If you are a member of a custom role, ensure that the portal administrator has granted you the Publish hosted web layers privilege.

Usage

  • You can geocode addresses that are stored in a single field or multiple fields. A single input field stores the complete address, for example, 303 Peachtree St NE, Atlanta, GA 30308. Multiple fields are supported if the input addresses are split into multiple fields such as Address, City, State, and ZIP for a general United States address.

  • Some locators support multiple input address fields such as Address, Address2, and Address3. In this case, the address component can be separated into multiple fields and the address fields will be concatenated at the time of geocoding. For example, 100, Main St, and Apt 140 across three fields or 100 Main St and Apt 140 across two fields both become 100 Main St Apt 140 when geocoding.

  • ArcGIS Enterprise 10.6 or later is required to use the tool.

  • Using a locator on the ArcGIS Enterprise portal that has been configured to use multiple threads will improve geocoding performance.

  • The tool requires that a table that is hosted or has been published on an ArcGIS Enterprise portal be used as the input table. Hosted tables are considered part of hosted feature layers and must be created as an item in the portal before they can be used in the tool. For details, see Publish hosted feature layers.

  • The output hosted feature layer is saved in the same spatial reference as the address locator. You can change the spatial reference of the output feature layer by setting a different output coordinate system in the tool's environment settings.

  • The output hosted feature layer will contain all relevant geocoding information, such as score, status, and the matched address of each record, as well as the values from the original input table. The addresses can be rematched using the Rematch Addresses tool or the Rematch Addresses option that opens the Rematch Addresses pane. The geocoding results from this tool contain a static snapshot of the original input table, so adding or updating any values in the original table will not update the results in the output feature service. The tool must be rerun to create a new output feature service that contains these changes.

    Learn more about rematching geocoding results

Syntax

arcpy.geocoding.GeocodeLocationsFromTable(in_table, in_address_locator, address_fields, output_name, {country}, {location_type}, {category}, {output_fields})
ParameterExplanationData Type
in_table

The table on the portal that contains addresses or places to geocode.

Record Set
in_address_locator

The portal locator that will be used to geocode the input table from the portal.

You can select a locator from the populated list of locators on the active portal or browse the active portal for other available locators. Locators that have been set as utility services in the active portal will be available by default. If the portal locator you want to use is not in the populated list, ask your portal administrator to add the locator as a portal utility service, and configure the locator for batch geocoding.

Note:

The ArcGIS World Geocoding Service is disabled for this tool. Use the Geocode Addresses tool if you want to use the ArcGIS World Geocoding Service.

Address Locator
address_fields
[input_locator_field, table_field_name]

Each field mapping in this parameter is in the format input_locator_field, table_field_name, where input_locator_field is the name of the input address field specified by the locator, and table_field_name is the name of the corresponding field in the table of addresses you want to geocode.

You can specify a single input field that stores the complete address, for example, 303 Peachtree St NE, Atlanta, GA 30308. Alternatively, you can specify multiple fields if the input addresses are split into multiple fields such as Address, City, State, and ZIP for a general United States address.

Some locators support multiple input address fields such as Address, Address2, and Address3. In this case, the address component can be separated into multiple fields and the address fields will be concatenated at the time of geocoding. For example, 100, Main St, and Apt 140 across three fields or 100 Main St and Apt 140 across two fields both become 100 Main St Apt 140 when geocoding.

If you choose not to map an optional input address field used by the locator to a field in the input table of addresses, specify that there is no mapping by using <None> in place of a field name.

Field Info
output_name

The name of the output geocoded feature layer that will be created on the portal.

String
country
[country,...]
(Optional)

The country or countries to search for the geocoded addresses. This parameter is available for locators that support a country parameter and will limit geocoding to the selected countries. Making a country selection will improve the accuracy of geocoding in most cases. If a field representing countries in the Input Table parameter is mapped to the Country Input Address Field, the country value from the Input Table parameter will override the Country parameter.

If no country is specified, geocoding is performed using all supported countries of the locator. Specify the input value as ISO 3166-1 3-character country codes.

The Country parameter is not supported for all locators.

String
location_type
(Optional)

Specifies the preferred output geometry for POINT_ADDRESS matches. The options for this parameter are ROUTING_LOCATION, which is the side of street location that can be used for routing and ADDRESS_LOCATION, which is the location that represents the rooftop, parcel centroid for the address, or front door. If the preferred location does not exist in the data, the default location of ROUTING_LOCATION will be returned. For geocode results with Addr_type=PointAddress, the x,y attribute values describe the coordinates of the address along the street, while the DisplayX and DisplayY values describe the rooftop or building centroid coordinates. See the REST API web help for details about the locationType parameter for reverseGeocode.

This parameter is not supported for all locators.

  • ADDRESS_LOCATIONGeometry for geocode results that represent an address location such as a rooftop location, parcel centroid, or front door is returned.
  • ROUTING_LOCATIONGeometry for geocode results that represent a location close to the side of the street that can be used for vehicle routing is returned. This is the default.
String
category
[category,...]
(Optional)

Limits the types of places the locator searches, eliminating false positive matches and potentially speeding up the search process. When no category is used, geocoding is performed using all supported categories. Not all category values are supported for all locations and countries. In general, the Category parameter can be used for the following:

  • Limit matches to specific place types or address levels
  • Avoid fallback matches to unwanted address levels
  • Disambiguate coordinate searches

This parameter is not supported for all locators.

See the REST API web help for details about category filtering.

String
output_fields
(Optional)

Specifies which locator output fields are returned in the geocode results.

Note:

This parameter can be used with input locators created with the Create Locator tool or Create Feature Locator tool published to Enterprise 10.9 or later. Composite locators that contain at least one locator created with the Create Address Locator tool do not support this parameter.

  • ALL Includes all available locator output fields in the geocode results. This is the default.
  • LOCATION_ONLYStores the Shape field in the geocode results. The original field names from the in_table are maintained with their original field names. Rematching geocode results is not available with this option.
  • MINIMALAdds the following fields that describe the location and how well it matches to information in the locator in the geocode results: Shape, Status, Score, Match_type, Match_addr, and Addr_type. The original field names from the in_table are maintained with their original field names.
String

Derived Output

NameExplanationData Type
output_layer

A hyperlink to the output geocoded results feature layer in the portal. The name of the feature layer is derived from the Output Feature Layer Name value.

Feature Set

Code sample

GeocodeLocationsFromTable example (stand-alone script)

The following stand-alone script demonstrates how to use the GeocodeLocationsFromTable function to geocode a hosted table layer.

import arcpy

arcpy.SignInToPortal("https://<machine_name>/<portal_web_adaptor_name>", 
                     '<username>', '<password>')

# Input is a hosted table
input_table = "https://<machine_name>/server/rest/services/Hosted/<item_name>/FeatureServer/<table_number>"

# This tool works with locators on your Portal
in_locator = "https://<machine_name>/server/rest/services/<locator_name>/GeocodeServer/<locator_name>"

# The easiest way to generate a field mapping is by running the tool in ArcGIS 
# Pro and Right-click the green success ribbon and click "Copy Python command"
field_mapping =  "'Street or Intersection' address VISIBLE NONE;'City or Placename' <None> VISIBLE NONE;State <None> VISIBLE NONE;'ZIP Code' zip VISIBLE NONE"
output_name = "geocoding_output"

# Optional geocoding parameters. Only some are supported depending on the 
# in_locator that you use.
country = None
location_type = None
category = None

# Note that the output is a hosted feature layer on your portal. To retrieve the
# output, go to your portal and look for a new item with the output_name that 
# you entered.
arcpy.geocoding.GeocodeLocationsFromTable(input_table, in_locator, 
                                          field_mapping, output_name, country, 
                                          location_type, category)

Licensing information

  • Basic: Requires your account in ArcGIS Enterprise to have the Perform Analysis privilege
  • Standard: Requires your account in ArcGIS Enterprise to have the Perform Analysis privilege
  • Advanced: Requires your account in ArcGIS Enterprise to have the Perform Analysis privilege

Related topics