HOW TO

Rematch a geocoded feature class using a different geocoding service

Last Published: April 25, 2020

Summary

When a shapefile or feature class is created by geocoding a table of addresses, a copy of the geocoding service that was used is attached to the shapefile or feature class. When rematching the addresses in the geocoded feature class, ArcGIS uses this copy of the geocoding service.Geocoded shapefiles and feature classes may contain addresses that could not be matched using the original geocoding service. In these cases, it may be desirable to rematch the unmatched addresses using a different geocoding service. For example, if a table of addresses is geocoded with a geocoding service based on the US Streets with Zone style, the remaining unmatched addresses can be matched to ZIP centroids using a geocoding service based on the ZIP (5-Digit) style. In order to accomplish this, a different geocoding service must first be attached to the geocoded shapefile or feature class.

Procedure



  1. In ArcCatalog, create the geocoding service you want to use to rematch the unmatched addresses in the geocoded shapefile or feature class.
  2. Paste the following VBA code into the VBA editor in ArcCatalog. This code assumes you already have a reference to the geocoded shapefile or feature class and to the geocoding service (in this case, a ZIP (5-Digit) geocoding service) you want to use to rematch the unmatched addresses. This code also assumes the geocoded shapefile or feature class has a field that contains the 5-digit ZIP code of the addresses (in this case, a field named "ARC_Zone").

    Code:
    Sub AttachNewLocator(pFeatureClass As IFeatureClass, _
    pLocator As ILocator)
    Const FIELD_ZIP_NAME = "ARC_Zone"
    Dim pLocatorAttach As ILocatorAttach
    Dim pLocatorDataset As ILocatorDataset
    Dim strMatchFields As String

    Set pLocatorDataset = pLocator
    Set pLocatorAttach = pLocatorDataset.LocatorWorkspace
    strMatchFields = MatchFields(pLocator)
    pLocatorAttach.AttachLocator pLocator, pFeatureClass, _
    pFeatureClass, FIELD_ZIP_NAME, pFeatureClass.OIDFieldName, _
    pFeatureClass, strMatchFields, pFeatureClass.OIDFieldName
    End Sub

    Function MatchFields(pAddressGeocoding As IAddressGeocoding) As String
    Dim i As Long
    Dim pMatchFields As IFields
    Dim strMatchFields() As String

    Set pMatchFields = pAddressGeocoding.MatchFields
    ReDim strMatchFields(pMatchFields.FieldCount - 1)
    For i = 0 To pMatchFields.FieldCount - 1
    strMatchFields(i) = pMatchFields.Field(i).Name
    Next i
    MatchFields = Join(strMatchFields, ",")
    End Function

  3. Write a procedure in VBA to obtain a reference to the geocoded shapefile or feature class and the geocoding service, and to call the AttachNewLocator procedure. There are numerous examples of how to obtain a reference to a shapefile or feature class in the ArcObjects Developer Help.
  4. Run your procedure to attach the new geocoding service to the geocoded shapefile or feature class.
  5. In ArcCatalog, rematch the unmatched addresses in the geocoded shapefile or feature class.

Article ID:000003504

Software:
  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic