Geocode Addresses (Geocoding)

Summary

Geocodes a table of addresses. This process requires a table that stores the addresses you want to geocode and an address locator or a composite address locator. This tool matches the stored addresses against the locator and saves the result for each input record in a new point feature class. When using the ArcGIS World Geocoding Service, this operation may consume credits.

Performing geocoding operations using the ArcGIS World Geocoding Service requires an ArcGIS organizational account, and it consumes credits. The organizational account must have enough credits to complete the entire geocoding request.

Note:

Credit estimation is available at the top of the tool when the active portal is ArcGIS Online and the input locator is the ArcGIS World Geocoding Service.

Usage

  • You can geocode addresses that are stored in a single field, divided into multiple fields, or stored in a single field and a country field. 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 divided into multiple fields such as Address, City, State, and ZIP for a general United States address. A single input field that stores the complete address, for example, 303 Peachtree St NE, Atlanta, GA 30308, and a field that stores the country associated with the address, for example, USA, is also supported.

  • 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.

  • The output feature class is saved in the same spatial reference as the address locator. To change the spatial reference of the output feature class, set a different output coordinate system in the tool's environment settings.

  • The output feature class, by default, stores a copy of the input address and additional information such as score, status, and matched address of each record. The addresses can be rematched using the Rematch Addresses tool or the Rematch Addresses option that opens the Rematch Addresses pane. Editing addresses in the input address table will not change the result in the output feature class once the matching process finishes and the feature class is created.

    Learn more about rematching geocoding results

  • An ArcGIS Online for organizations subscription is required to match a table of addresses using the ArcGIS World Geocoding Service.

  • To generate the correct Python syntax, first run the tool from the Geoprocessing pane using the appropriate parameter options. Then open the Run menu and choose the Copy Python Command option.

  • When geocoding a table of addresses or places with a z-aware locator, use this tool in a local scene. The z-aware geocode results will be automatically added to the local scene with the elevation properties set to the At an absolute height option Elevation Absolute Height.

    If the local scene contains the elevation surface that was used to digitize the point reference data that was used to build the locator, set the elevation properties of the geocode results to the At an absolute height option Elevation Absolute Height. This can be done on the Layer Properties dialog box on the Elevation tab. If the elevation surface used to create the reference data is not in the local scene, set the elevation of the geocode results to the Relative to the ground option Elevation Relative To Ground.

    Learn more about defining height characteristics for layers

Parameters

LabelExplanationData Type
Input Table

The table of addresses to geocode.

Table View
Input Address Locator

The address locator that will be used to geocode the table of addresses.

Note:

Including the .loc extension after the locator name at the end of the locator path is optional.

Address Locator
Input Address Fields

The mapping of address fields used by the address locator to fields in the input table of addresses. Select Single Field if the complete address is stored in one field in the input table, for example, 303 Peachtree St NE, Atlanta, GA 30308. Select Multiple Fields if the input addresses are divided into multiple fields such as Address, City, State, and ZIP for a general United States address. Select Single Field and Country Field if the complete address and the country are split into separate fields such as Address (303 Peachtree St NE, Atlanta, GA 30308) and Country (USA).

Some locators support multiple input addresses 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 do not map an optional input address field used by the address locator to a field in the input table of addresses, specify that there is no mapping using <None> in place of the field name.

Field Info
Output Feature Class

The output geocoded feature class.

Note:

Saving the output to shapefile format is not supported due to shapefile limitations.

Feature Class
Dynamic Output Feature Class
(Optional)

This parameter is inactive in ArcGIS AllSource. It remains to support backward compatibility with ArcGIS Desktop.

Boolean
Country
(Optional)

The country or countries that will be searched for the geocoded addresses.

This parameter is available for locators that support a country parameter and will limit geocoding to the selected countries. Specifying a country will improve the accuracy of geocoding in most cases. When you select Single Field and Country Field for the Input Address Fields parameter and map a field representing countries using the Input Table parameter value to the Country field for the Input Address Fields parameter value, the country value from the Input Table parameter will override the Country parameter.

This is limited to the specified country or countries. When no country is specified, geocoding is performed using all supported countries of the locator.

The Country parameter is not supported for all locators.

String
Preferred Location Type
(Optional)

Specifies the preferred output geometry for PointAddress 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 or parcel centroid for the address. If the preferred location does not exist in the data, the default 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, and the DisplayX and DisplayY values describe the rooftop or building centroid coordinates.

This parameter is not supported for all locators.

  • Address locationGeometry for geocode results that represent an address location such as rooftop location, parcel centroid, or front door will be returned.
  • Routing locationGeometry for geocode results that represent a location close to the side of the street that can be used for vehicle routing will be returned. This is the default.
String
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, this 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 ArcGIS REST API web help for details about category filtering.

String
Output Fields
(Optional)

Specifies the locator output fields that will be returned in the geocode results.

  • 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 Input Table parameter value will be maintained with their original field names.
  • MinimalAdds the following fields that describe the location and how well it matches information in the locator in the geocode results: Shape, Status, Score, Match_type, Match_addr, and Addr_type. The original field names from the Input Table parameter value will be maintained.
  • Minimal and User FieldsAdds the following fields that describe the location and how well it matches information in the locator, as well as any user-defined custom output fields in the geocode results: Shape, Status, Score, Match_type, Match_addr, and Addr_type. The original field names from the Input Table parameter value will be maintained.
Note:

This parameter can be used with input locators created with the Create Locator or Create Feature Locator tool stored on disk or 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.

String

arcpy.geocoding.GeocodeAddresses(in_table, address_locator, in_address_fields, out_feature_class, {out_relationship_type}, {country}, {location_type}, {category}, {output_fields})
NameExplanationData Type
in_table

The table of addresses to geocode.

Table View
address_locator

The address locator that will be used to geocode the table of addresses.

Note:

Including the .loc extension after the locator name at the end of the locator path is optional.

Address Locator
in_address_fields
[input_address_field, table_field_name]

Each field mapping in this parameter is in the format input_address_field, table_field_name in which input_address_field is the name of the input address field specified by the address 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 divided into multiple fields such as Address, City, State, and ZIP for a general United States address. You can also specify a single input field that stores the complete address, for example, 303 Peachtree St NE, Atlanta, GA 30308, and a field that stores the country associated with the address, for example, USA.

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 do not map an optional input address field used by the address locator to a field in the input table of addresses, specify that there is no mapping using <None> in place of the field name.

Field Info
out_feature_class

The output geocoded feature class.

Note:

Saving the output to shapefile format is not supported due to shapefile limitations.

Feature Class
out_relationship_type
(Optional)
Legacy:

This parameter has no effect in ArcGIS AllSource. It remains to support backward compatibility with ArcGIS Desktop.

In ArcGIS AllSource, the only permissible value is STATIC.

  • STATICA static copy of the fields input address table will be created in the output feature class. This is the only permissible value.
  • DYNAMICThis option is not applicable in ArcGIS AllSource. See the ArcGIS Desktop help for this tool.
Boolean
country
[country,...]
(Optional)

The country or countries that will be searched for the geocoded addresses.

This parameter is available for locators that support a country parameter and will limit geocoding to the selected countries. Specifying a country will improve the accuracy of geocoding in most cases. If a field representing countries in the in_table parameter is mapped to the Country field in the input_address_field parameter value, the country value from the in_table parameter will override the country parameter.

This is limited to the specified country or countries. When no country is specified, geocoding is performed using all supported countries of the locator.

Specify the value as either two-character or three-character country codes in a comma-separated list. See the Supported Country Codes column for the input value to use.

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, and the DisplayX and DisplayY values describe the rooftop or building centroid coordinates. See the ArcGIS REST API web help for details about the locationType parameter for geocodeAddresses.

This parameter is not supported for all locators.

  • ADDRESS_LOCATIONGeometry for geocode results that represent an address location such as rooftop location, parcel centroid, or front door will be returned.
  • ROUTING_LOCATIONGeometry for geocode results that represent a location close to the side of the street that can be used for vehicle routing will be 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, this 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 ArcGIS REST API web help for details about category filtering.

String
output_fields
(Optional)

Specifies the locator output fields that will be returned in the geocode results.

Note:

This parameter can be used with input locators created with the Create Locator or Create Feature Locator tool stored on disk or 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 parameter value will be maintained with their original field names.
  • MINIMALAdds the following fields that describe the location and how well it matches 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 parameter value will be maintained.
  • MINIMAL_AND_USERAdds the following fields that describe the location and how well it matches information in the locator in the geocode results, as well as any user-defined custom output fields: Shape, Status, Score, Match_type, Match_addr, and Addr_type. The original field names from the in_table parameter value will be maintained.
String

Code sample

GeocodeAddresses example (stand-alone script)

The following script demonstrates how to use the GeocodeAddresses function to geocode a table of addresses with a local locator.

import arcpy

arcpy.env.workspace = "C:\Geocoding\atlanta"

# Set local variables
table = "customers.dbf"
locator = "Atlanta_AddressLocator.loc"
field_map = ("\'Address or Place\' Address VISIBLE NONE;Address2 <None> VISIBLE NONE;Address3 <None> VISIBLE NONE;" +
                  "Neighborhood <None> VISIBLE NONE;City <None> VISIBLE NONE;County <None> VISIBLE NONE;" +
                  "State <None> VISIBLE NONE;ZIP ZIP <None> VISIBLE NONE;ZIP4 <None> VISIBLE NONE;" +
                  "Country <None> VISIBLE NONE")
geocode_result = "geocode_result.shp"

arcpy.geocoding.GeocodeAddresses(table, locator, 
                                 field_map, geocode_result)
GeocodeAddresses example 2 (stand-alone script)

The following script demonstrates how to use the GeocodeAddresses function to geocode a table of addresses with a server locator through an AGS connection.

import arcpy

# Set local variables:
table = r"C:\data\Atlanta.gdb\customers"
locator = r"C:\ags_connections\server_name.ags\Atlanta.GeocodeServer"
field_map = "'Single Line Input' SingleLine VISIBLE NONE"
geocode_result = r"C:\outputs\geocode_result.shp"

arcpy.geocoding.GeocodeAddresses(table, locator,
                                 field_map, geocode_result)
GeocodeAddresses example 3 (stand-alone script)

The following script demonstrates how to use the GeocodeAddresses function to geocode a table of addresses with a portal locator.

Note:

If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS AllSource. To access a locator that is on a portal other than your active portal, you can authenticate using the SignInToPortal function.

import arcpy

# Set local variables
table = r"C:\data\Atlanta.gdb\customers"
locator = "https://machinename.domain.com/server/rest/services/service_name/GeocodeServer/portal_item_name"
field_map = ("\'Address or Place\' Address VISIBLE NONE;Address2 <None> VISIBLE NONE;Address3 <None> VISIBLE NONE;" +
                  "Neighborhood <None> VISIBLE NONE;City <None> VISIBLE NONE;County <None> VISIBLE NONE;" +
                  "State <None> VISIBLE NONE;ZIP ZIP <None> VISIBLE NONE;ZIP4 <None> VISIBLE NONE;" +
                  "Country <None> VISIBLE NONE")
geocode_result = r"C:\outputs\geocode_result.shp"

arcpy.geocoding.GeocodeAddresses(table, locator, field_map, geocode_result)
GeocodeAddresses example 4 (stand-alone script)

The following script demonstrates how to use the GeocodeAddresses function to geocode a table of addresses with the ArcGIS World Geocoding Service.

Note:

If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS AllSource. To access a locator that is on a portal other than your active portal, you can authenticate using the SignInToPortal function.

Note:

When using the ArcGIS World Geocoding Service, this operation may consume credits.

import arcpy

# Set local variables
table = r"C:\data\Addresses.csv"

# Sign in to Portal
#arcpy.SignInToPortal("https://www.arcgis.com.", "MyUsername", "MyPassword")

locator = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service"

field_map = ("\'Address or Place\' Address VISIBLE NONE;Address2 <None> VISIBLE NONE;Address3 <None> VISIBLE NONE;" +
             "Neighborhood <None> VISIBLE NONE;City <None> VISIBLE NONE;Subregion <None> VISIBLE NONE;" +
             "Region <None> VISIBLE NONE;ZIP ZIP <None> VISIBLE NONE;ZIP4 <None> VISIBLE NONE;" +
             "Country <None> VISIBLE NONE")

geocode_result = r"C:\outputs\geocode_result.shp"

arcpy.geocoding.GeocodeAddresses(table, locator, field_map, geocode_result)
GeocodeAddresses example 5 (stand-alone script)

The following script demonstrates how to use the GeocodeAddresses function to geocode a table of addresses—in which all address data is in a single field and country data is in a second field—with the ArcGIS World Geocoding Service.

Note:

If you are working with locators on your portal, ensure that you are signed in and have it set as your active portal in ArcGIS AllSource. To access a locator that is on a portal other than your active portal, you can authenticate using the SignInToPortal function.

Note:

When using the ArcGIS World Geocoding Service, this operation may consume credits.

import arcpy

# Set local variables
table = r"C:\Data\MyDatabase.gdb\DistributionCenters"

# Sign in to Portal
#arcpy.SignInToPortal("https://www.arcgis.com.", "MyUsername", "MyPassword")

locator = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service"

field_map = "'Single Line Input' SingleLine VISIBLE NONE;Country Country VISIBLE NONE"

geocode_result = r"C:\Data\MyDatabase.gdb\DistributionCenters_Geocoded"

arcpy.geocoding.GeocodeAddresses(table, locator, field_map, geocode_result)