How to standardize an address


In this topic


Using geoprocessing

Do the following steps to standardize an address table using geoprocessing:
  1. Gather the address data that needs to be standardized.
  2. Determine which fields need the standardization.
  3. Determine the locator style with which the addresses need to be standardized.
  4. Select the output fields for the standardized addresses.

    See the following code example:
[VB.NET]
Public Sub StandardizeAddressesTool()
    Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor
    Dim standardizeAddresses As StandardizeAddresses = New StandardizeAddresses()
    standardizeAddresses.in_address_data = "C:\UnitedStates.gdb\addresses"
    standardizeAddresses.in_input_address_fields = "Address"
    standardizeAddresses.in_address_locator_style = "US Address - Dual Ranges"
    standardizeAddresses.in_output_address_fields = "HouseNum;PreDir;PreType;StreetName;SufType;SufDir"
    standardizeAddresses.out_address_data = "C:\UnitedStates.gdb\Address_Table_Standardized"
    standardizeAddresses.in_relationship_type = "Static"
    Try
    Dim result As IGeoProcessorResult = GP.Execute(standardizeAddresses, Nothing)
    If (Not result Is Nothing) Then
        If (Not result.Status = esriJobStatus.esriJobSucceeded) Then
            Console.WriteLine("Failed to standardize the address table: ")
        Else
            Console.WriteLine("Standardize Addresses completed successfully. ")
        End If
    Else
        If (Not GP.MessageCount = 0) Then
            For i As Integer = 0 To GP.MessageCount - 1
                Console.WriteLine("GP Message " & i & " " + GP.GetMessage(i))
            Next
        Else
            Console.WriteLine("Execution failed with no status. ")
        End If
    End If
    Catch ex As Exception
    Console.WriteLine("An Exception occured while executing the StandardizeAddresses Tool:  " & ex.ToString())
    End Try
End Sub
[C#]
public void StandardizeAddressesTool()
{
    Geoprocessor GP = new Geoprocessor();
    StandardizeAddresses standardizeAddresses = new StandardizeAddresses();
    standardizeAddresses.in_address_data = "C:\\UnitedStates.gdb\\addresses";
    standardizeAddresses.in_input_address_fields = "Address";
    standardizeAddresses.in_address_locator_style = "US Address - Dual Ranges";
    standardizeAddresses.in_output_address_fields = 
        "HouseNum;PreDir;PreType;StreetName;SufType;SufDir";
    standardizeAddresses.out_address_data = 
        "C:\\UnitedStates.gdb\\Address_Table_Standardized";
    standardizeAddresses.in_relationship_type = "Static";
    try
    {
        IGeoProcessorResult result = GP.Execute(standardizeAddresses, null)as
            IGeoProcessorResult;
        if (result != null)
        {
            if (result.Status != esriJobStatus.esriJobSucceeded)
                Console.WriteLine("Failed to standardize the address table: ");
            else
                Console.WriteLine("Standardize Addresses completed successfully. ");
        }
        else
        {
            if (GP.MessageCount != 0)
            {
                for (int i = 0; i < GP.MessageCount; i++)
                {
                    Console.WriteLine("GP Message " + i + " " + GP.GetMessage(i));
                }
            }
            else
                Console.WriteLine("Execution failed with no status. ");
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(
            "An Exception occured while executing the StandardizeAddresses Tool:  " 
            + e);
    }
}

Using ArcObjects

Locators and locator styles support the ISimpleStandardization interface, which can be used to standardize single addresses, or tables and feature classes containing address information. The most common usage for this interface is to use the SimpleStandardizeTable method to standardize the address information in a feature class used as reference data for a locator.
Standardize address information in reference data feature classes. This allows address locators that were created using the reference data feature classes to standardize addresses the same way as standardized in the reference data.
The InputTable parameter is a reference to the table or feature class containing the address information that you want to standardize. The inputFieldsToConcatenate parameter is a comma-delimited string containing the field names in the input dataset that when concatenated, form an address that can be standardized.
When standardizing a dataset, create the table or feature class that contains the standardized records and pass it to the SimpleStandardizeTable method using the OutputTable parameter. At a minimum, the standardized dataset must contain an ObjectID field and all the standardization fields defined by the SimpleStandardizeFields property. Create a shape field in the output dataset (that is, create an output feature class) if you are standardizing the address information in a feature class, and to copy the shapes from the input feature class to the output feature class.
The outputFieldNames parameter is a comma-delimited string that contains the names of the standardization fields in the standardized dataset. Specify the field names in this string in the same order as the field objects in the fields collection returned by the SimpleStandardizeFields property.
The fieldsToCopy parameter is a PropertySet defining the fields from the input dataset to copy to the output dataset. The property names are the field names in the output dataset and the property names are the corresponding field names in the input dataset.
Include a numeric field that can represent a house number in this set of field names.
The following code example shows how to standardize the address information in a feature class using the ISimpleStandardization interface:
[VB.NET]
Public Sub StandardizeAddress()
    
    ' Open an ArcSDE workspace.
    Dim propertySet_Connection As IPropertySet = New PropertySetClass
    With propertySet_Connection
        .SetProperty("server", "mendota")
        .SetProperty("instance", "esri_sde")
        .SetProperty("database", "arcobjects")
        .SetProperty("user", "sde")
        .SetProperty("password", "sde")
        .SetProperty("version", "SDE.Default")
    End With
    
    Dim obj As System.Object = Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"))
    Dim workspaceFactory As IWorkspaceFactory = CType(obj, IWorkspaceFactory)
    Dim workspace As IWorkspace = workspaceFactory.Open(propertySet_Connection, 0)
    Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace)
    
    ' Open the feature class to standardize.
    Dim featureClass As IFeatureClass = featureWorkspace.OpenFeatureClass("arcobjects.SDE.Redlands_Street")
    
    ' Get the locator style to use to standardize the feature class.
    obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"))
    Dim locatorManager As ILocatorManager = CType(obj, ILocatorManager)
    Dim workspace_Locator As IWorkspace = CType(featureWorkspace, IWorkspace)
    Dim locatorWorkspace As ILocatorWorkspace = locatorManager.GetLocatorWorkspaceFromPath("")
    Dim locatorStyle As ILocatorStyle = locatorWorkspace.GetLocatorStyle("US Address - Dual Ranges")
    Dim simpleStandardization As ISimpleStandardization = CType(locatorStyle, ISimpleStandardization)
    
    ' Create the feature class in which to write the standardization results.
    ' The feature class must contain an ObjectID field, a shape field, and the standardization fields.
    Dim fieldsEdit As IFieldsEdit = CType(New FieldClass, IFieldsEdit)
    Dim fieldEdit As IFieldEdit = New FieldClass
    fieldEdit.Name_2 = "ObjectID"
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeOID
    fieldsEdit.AddField(fieldEdit)
    Dim string_ShapeFieldName As String = featureClass.ShapeFieldName
    Dim fields As IFields = featureClass.Fields
    Dim int32_FieldIndex As Int32 = fields.FindField(string_ShapeFieldName)
    Dim field As IField = fields.Field(int32_FieldIndex)
    fieldsEdit.AddField(field)
    Dim fieldsStandardization As IFields = simpleStandardization.SimpleStandardizeFields
    
    Dim strStandardizedFieldNames() As String
    ReDim strStandardizedFieldNames(0 To fieldsStandardization.FieldCount - 1)
    
    Dim int32_StandardizationFieldsIndex As Int32
    For int32_StandardizationFieldsIndex = 0 To fieldsStandardization.FieldCount - 1
        Dim field_Standardization As IField = fieldsStandardization.Field(int32_StandardizationFieldsIndex)
        fieldsEdit.AddField(field_Standardization)
        strStandardizedFieldNames(int32_StandardizationFieldsIndex) = field_Standardization.Name
    Next int32_StandardizationFieldsIndex
    
    Dim pUID As UID = New UIDClass
    pUID.Value = "esriGeodatabase.Feature"
    
    Dim featureClass_Standardized As IFeatureClass = featureWorkspace.CreateFeatureClass("Redlands_Standardized", fieldsEdit, pUID, Nothing, esriFeatureType.esriFTSimple, string_ShapeFieldName, "")
    
    ' Standardize the feature class.
    Dim propertySet_FieldsToCopy As IPropertySet = New PropertySetClass

    propertySet_FieldsToCopy.SetProperty(string_ShapeFieldName, string_ShapeFieldName)
        Dim table_FeatureClass As ITable = CType(featureClass, ITable)
        Dim table_FeatureClassStandardized As ITable = CType(featureClass_Standardized, ITable)
        simpleStandardization.SimpleStandardizeTable(table_FeatureClass, "OBJECTID,FULL_NAME", "", table_FeatureClassStandardized, Microsoft.VisualBasic.Strings.Join(strStandardizedFieldNames, ","), propertySet_FieldsToCopy, Nothing)
        
    End Sub
[C#]
public void StandardizeAddress()
{
    // Open an ArcSDE workspace.
    IPropertySet propertySet_Connection = new PropertySetClass();
    propertySet_Connection.SetProperty("server", "mendota");
    propertySet_Connection.SetProperty("instance", "esri_sde");
    propertySet_Connection.SetProperty("database", "arcobjects");
    propertySet_Connection.SetProperty("user", "sde");
    propertySet_Connection.SetProperty("password", "sde");
    propertySet_Connection.SetProperty("version", "SDE.Default");

    System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID(
        "esriDataSourcesGDB.SdeWorkspaceFactory"));
    IWorkspaceFactory workspaceFactory = obj as IWorkspaceFactory;
    IWorkspace workspace = workspaceFactory.Open(propertySet_Connection, 0);
    IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;

    // Open the feature class to standardize.
    IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(
        "arcobjects.SDE.Redlands_Street");

    // Get the locator style to use to standardize the feature class.
    obj = Activator.CreateInstance(Type.GetTypeFromProgID(
        "esriLocation.LocatorManager"));
    ILocatorManager locatorManager = obj as ILocatorManager;
    IWorkspace workspace_Locator = (IWorkspace)featureWorkspace;
    ILocatorWorkspace locatorWorkspace = locatorManager.GetLocatorWorkspaceFromPath(
        "");
    ILocatorStyle locatorStyle = locatorWorkspace.GetLocatorStyle(
        "US Address - Dual Ranges");
    ISimpleStandardization simpleStandardization = (ISimpleStandardization)
        locatorStyle;

    // Create the feature class in which to write the standardization results.
    // The feature class must contain an ObjectID field, a shape field, and the standardization fields.
    IFieldsEdit fieldsEdit = (IFieldsEdit)(new FieldClass());
    IFieldEdit fieldEdit = new FieldClass();
    fieldEdit.Name_2 = "ObjectID";
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
    fieldsEdit.AddField(fieldEdit);
    string string_ShapeFieldName = featureClass.ShapeFieldName;
    IFields fields = featureClass.Fields;
    Int32 int32_FieldIndex = fields.FindField(string_ShapeFieldName);
    IField field = fields.get_Field(int32_FieldIndex);
    fieldsEdit.AddField(field);
    IFields fieldsStandardization = simpleStandardization.SimpleStandardizeFields;

    string[] strStandardizedFieldNames = null;
    strStandardizedFieldNames = new string[fieldsStandardization.FieldCount];

    Int32 int32_StandardizationFieldsIndex = 0;
    for (int32_StandardizationFieldsIndex = 0; int32_StandardizationFieldsIndex <
        fieldsStandardization.FieldCount; int32_StandardizationFieldsIndex++)
    {
        IField field_Standardization = fieldsStandardization.get_Field
            (int32_StandardizationFieldsIndex);
        fieldsEdit.AddField(field_Standardization);
        strStandardizedFieldNames[int32_StandardizationFieldsIndex] =
            field_Standardization.Name;
    }

    UID pUID = new UIDClass();
    pUID.Value = "esriGeodatabase.Feature";

    IFeatureClass featureClass_Standardized = featureWorkspace.CreateFeatureClass(
        "Redlands_Standardized", fieldsEdit, pUID, null,
        esriFeatureType.esriFTSimple, string_ShapeFieldName, "");

    // Standardize the feature class.
    IPropertySet propertySet_FieldsToCopy = new PropertySetClass();
    propertySet_FieldsToCopy.SetProperty(string_ShapeFieldName,
        string_ShapeFieldName);
    ITable table_FeatureClass = (ITable)featureClass;
    ITable table_FeatureClassStandardized = (ITable)featureClass_Standardized;
    simpleStandardization.SimpleStandardizeTable(table_FeatureClass, 
        "OBJECTID,FULL_NAME", "", table_FeatureClassStandardized,
        Microsoft.VisualBasic.Strings.Join(strStandardizedFieldNames, ","),
        propertySet_FieldsToCopy, null);
}


See Also:

Location library overview




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):