Summary
Geocodes hosted tables using locators hosted on an ArcGIS Enterprise portal, which creates a hosted feature layer containing the geocoded results.
This tool is designed to automate the process of geocoding tables published to the portal and saving the output to the portal. If you are not interested in saving the geocode results to the portal, use the Geocode Table pane or the Geocode Addresses tool.
Note:
This tool requires that you have publisher or administrator privileges on the portal. If you are a member of a custom role, be sure 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 together 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 would 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. Changing the spatial reference of the output feature layer is possible 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 will need to be rerun to create a new output feature service that contains these changes.
Syntax
GeocodeLocationsFromTable(in_table, in_address_locator, address_fields, output_name, {country}, {location_type}, {category})
Parameter | Explanation | Data 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. A populated list of locators on the active portal. You can select a locator from this list 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 one 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 together 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 would 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 is mapped to the Country Input Address Field, the country value from the Input Table will override the Country parameter. If no country is specified, geocoding is performed against all supported countries of the locator. The input value should be specified as ISO 3166-1 3-character country codes. Country 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, the side of street location that can be used for routing, or ADDRESS_LOCATION, 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 instead. 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.
| String |
category [category,...] (Optional) | Limits the types of places the locator searches, thus eliminating false positive matches and potentially speeding up the search process. When no category is used, geocoding is performed against 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:
This parameter is not supported for all locators. See the REST API web help for details about category filtering. | String |
Derived Output
Name | Explanation | Data Type |
output_layer | A hyperlink to the output geocoded results feature layer in the portal. The name of the feature layer is derived from text specified in Output Feature Layer Name. | Feature Set |
Code sample
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)
Environments
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