Geographic Information Systems Asked by pmk58 on October 12, 2020
I have a table of about 1500 addresses that updates and geocodes nightly using task scheduler and a couple of python scripts. The majority of these addresses are in the county for which I work. We have a local composite locator that can get all these addresses no problem, but the locator fails to match the addresses outside the county because it is built on county-wide datasets. The addresses that do occur outside the county range all over the United States.
So, instead I have it set up to connect to and use the ESRI World Geocoding service to geocode the addresses each night, which works like a charm. However, with 1500+ addresses geocoding nightly, this is very credit-intensive, and since we can geocode the majority of them without using the service, I am looking for a way to use our local locator first, and then rematch the unmatched (out of county) addresses using the ESRI World Geocoding service. Any thoughts?
ESRI has a 2016 post that says you can do this with VB. https://support.esri.com/en/technical-article/000003504
I've never done this, but straight from their site it mentions the following steps:
- Procedure In ArcCatalog, create the geocoding service you want to use to rematch the unmatched addresses in the geocoded shapefile or feature class.
- 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
- 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.
- Run your procedure to attach the new geocoding service to the geocoded shapefile or feature class.
- In ArcCatalog, rematch the unmatched addresses in the geocoded shapefile or feature class.
Answered by siushi on October 12, 2020
You could do this in python. I would suggest that you use a Boolean, and to start off set it to false.
Example:
candidateFound = False
Then with candidateFound == False, make a call to your local geocoder, if candidate is found then set candidateFound = True. Else if candidateFound = False then make you call to the ESRI world geocoder.
With the Boolean you are controlling what address is sent to using your credits.
Answered by enolan on October 12, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP