Is This Content Helpful?
We're glad to know this article was helpful.
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.
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
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
MatchFields = Join(strMatchFields, ",")