How to create a composite address locator


Summary A composite address locator consists of two or more individual address locators that allow addresses to be matched against multiple address locators and find the best matches.

In this topic


Building a composite address locator

Do the following steps to build composite address locators:
  1. Create individual address locators.
  2. Determine the input address fields for the composite locator. To find an address, these are the fields that the individual locators are mapped to.
  3. Specify the input field mapping of each locator's input address fields to the input address fields of the composite address locator.
  4. Specify the selection criteria for the individual address locator if you want to specify the locator that is used for a particular address based on the criteria (optional).
  5. Specify where to store the output composite address locator. 

Using geoprocessing to create a composite address locator

Use geoprocessing to create a composite address locator. See the following code example:
[C#]
public void CreateCompositeAddressLocatorTool()
{
    Geoprocessor GP = new Geoprocessor();

    CreateCompositeAddressLocator createCompositeAddressLocator = new
        CreateCompositeAddressLocator();
    String locator1Path = @"C:\California.gdb\California_city_state_zip_94";
    String locator1Name = "cal_locator";
    String locator2Path = @"C:\California.gdb\rialto_locator_94";
    String locator2Name = "rialto_locator";

    // You need a semicolon between each locator.
    createCompositeAddressLocator.in_address_locators = locator1Path + " " +
        locator1Name + ";" + locator2Path + " " + locator2Name;

    /********** ADDRESS Field Mapping **********/
    // The field that the locator fields will be mapped to.
    // Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    String mappedAddressField = 
        "Address 'Street or Intersection' true true false 100 Text 0 0";

    // Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    String mappedLocator1AddressField = locator1Path + ",Address,0,0";
    String mappedLocator2AddressField = locator2Path + ",Address,0,0";

    // Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    String addressField = mappedAddressField + @" ,First,#," +
        mappedLocator1AddressField + "," + mappedLocator2AddressField;
    /******** End ADDRESS Field Mapping ********/

    /*********** CITY Field Mapping ************/
    // The field the locator fields will be mapped to.
    // Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    String mappedCityField = "City 'City or Placename' true true false 40 Text 0 0";

    // Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    String mappedLocator1CityField = locator1Path + ",City,0,0";
    String mappedLocator2CityField = locator2Path + ",City,0,0";

    // Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    String cityField = mappedCityField + @" ,First,#," + mappedLocator1CityField + 
        "," + mappedLocator2CityField;
    /********* End CITY Field Mapping **********/

    /*********** STATE Field Mapping ***********/
    // The field the locator fields will be mapped to.
    // Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    String mappedStateField = "State 'State' true true false 20 Text 0 0";

    // Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    String mappedLocator1StateField = locator1Path + ",State,0,0";
    String mappedLocator2StateField = locator2Path + ",State,0,0";

    // Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    String stateField = mappedStateField + @" ,First,#," + mappedLocator1StateField 
        + "," + mappedLocator2StateField;
    /********* End STATE Field Mapping *********/

    /************ ZIP Field Mapping ************/
    // The field that the locator fields will be mapped to.
    // Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    String mappedZipField = "Zip 'Zipcode' true true false 10 Text 0 0";

    // Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    String mappedLocator1ZipField = locator1Path + ",Zip,0,0";
    String mappedLocator2ZipField = locator2Path + ",Zip,0,0";

    // Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    String zipField = mappedZipField + @" ,First,#," + mappedLocator1ZipField + "," 
        + mappedLocator2ZipField;
    /********** End ZIP Field Mapping **********/

    // You need a semicolon between each mapped field.
    createCompositeAddressLocator.in_field_map = addressField + ";" + cityField + 
        ";" + stateField + ";" + zipField;

    // The selection criteria for specific locators.
    // Syntax('*' means 'use as is') = locator1Name selectionCriteria;locator2Name selectionCriteria  ......
    createCompositeAddressLocator.in_selection_criteria = locator1Name + " #;" +
        locator2Name + " '\"City\" = 'rialto''";
    createCompositeAddressLocator.out_composite_address_locator = @
        "C:\California.gdb\California_Composite_Locator";
    try
    {
        IGeoProcessorResult result = GP.Execute(createCompositeAddressLocator, null)
            as IGeoProcessorResult;

        if (result != null)
        {
            if (result.Status != esriJobStatus.esriJobSucceeded)
                Console.WriteLine("Failed to create the composite address Locator: ")
                    ;
            else
                Console.WriteLine("Created the composite address Locator. ");
        }
        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 CreateCompositeAddressLocator Tool:  " + e);
    }
}
[VB.NET]
Public Sub CreateCompositeAddressLocatorTool()
    Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor
    Dim createCompositeAddressLocator As CreateCompositeAddressLocator = New CreateCompositeAddressLocator
    Dim locator1Path As String = "C:\California.gdb\California_city_state_zip_94"
    Dim locator1Name As String = "cal_locator"
    Dim locator2Path As String = "C:\California.gdb\rialto_locator_94"
    Dim locator2Name As String = "rialto_locator"
    
    ' You need a semicolon between each locator.
    createCompositeAddressLocator.in_address_locators = locator1Path & " " & locator1Name & ";" & locator2Path & " " & locator2Name
    
    '********** ADDRESS Field Mapping **********'
    '' The field the locator fields will be mapped to.
    '' Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    Dim mappedAddressField As String = "Address 'Street or Intersection' true true false 100 Text 0 0"
    
    '' Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    Dim mappedLocator1AddressField As String = locator1Path & ",Address,0,0"
    Dim mappedLocator2AddressField As String = locator2Path & ",Address,0,0"
    
    '' Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    Dim addressField As String = mappedAddressField & " ,First,#," & mappedLocator1AddressField & "," & mappedLocator2AddressField
    '******** End ADDRESS Field Mapping ********'
    
    '*********** CITY Field Mapping ************'
    '' The field that the locator fields will be mapped to.
    '' Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    Dim mappedCityField As String = "City 'City or Placename' true true false 40 Text 0 0"
    
    '' Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    Dim mappedLocator1CityField As String = locator1Path & ",City,0,0"
    Dim mappedLocator2CityField As String = locator2Path & ",City,0,0"
    
    '' Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    Dim cityField As String = mappedCityField & " ,First,#," & mappedLocator1CityField & "," & mappedLocator2CityField
    '********* End CITY Field Mapping **********'
    
    '*********** STATE Field Mapping ***********'
    '' The field that the locator fields will be mapped to.
    '' Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    Dim mappedStateField As String = "State 'State' true true false 20 Text 0 0"
    
    '' Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    Dim mappedLocator1StateField As String = locator1Path & ",State,0,0"
    Dim mappedLocator2StateField As String = locator2Path & ",State,0,0"
    
    '' Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    Dim stateField As String = mappedStateField & " ,First,#," & mappedLocator1StateField & "," & mappedLocator2StateField
    '********* End STATE Field Mapping *********'
    
    '************ ZIP Field Mapping ************'
    '' The field that the locator fields will be mapped to.
    '' Syntax('*' means 'use as is') = fieldName(no spaces) 'alias name' *true *true isRequiredField fieldSize *Text *0 *0.
    Dim mappedZipField As String = "Zip 'Zipcode' true true false 10 Text 0 0"
    
    '' Syntax('*' means 'use as is') = locatorPath,locatorFieldName,*0,*0.
    Dim mappedLocator1ZipField As String = locator1Path & ",Zip,0,0"
    Dim mappedLocator2ZipField As String = locator2Path & ",Zip,0,0"
    
    '' Syntax('*' means 'use as is') = mappedField(See Above) ,*First,*#,mappedLocator1Field(See Above),mappedLocator2Field(See Above).
    Dim zipField As String = mappedZipField & " ,First,#," & mappedLocator1ZipField & "," & mappedLocator2ZipField
    '********** End ZIP Field Mapping **********'
    
    ' You need a semicolon between each field.
    createCompositeAddressLocator.in_field_map = addressField & ";" & cityField & ";" & stateField & ";" & ZipField
    
    ' The selection criteria for specific locators.
    createCompositeAddressLocator.in_selection_criteria = locator1Name + " #;" + locator2Name + "'" & ControlChars.Quote & "City" & ControlChars.Quote & " = 'rialto''"
    createCompositeAddressLocator.out_composite_address_locator = "C:\California.gdb\California_Composite_Locator"
    
    Try
    Dim result As IGeoProcessorResult = GP.Execute(createCompositeAddressLocator, Nothing)
    
    If (Not result Is Nothing) Then
        If (Not result.Status = esriJobStatus.esriJobSucceeded) Then
            Console.WriteLine("Failed to create the composite address Locator: ")
        Else
            Console.WriteLine("Created the composite address Locator. ")
        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 CreateCompositeAddressLocator Tool:  " & ex.ToString())
    End Try
End Sub


See Also:

Creating an address locator




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):
Development licensing Deployment licensing
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime