Select to view content in your preferred language

ERROR 000005: Could not open the address locator.

2661
11
11-27-2019 07:24 AM
JoeBorgione
MVP Emeritus

ArcGis Pro 2.4 and/or ArcGIS 1.6.1

I am attempting to automate the creation of a composite locator using the Create Composite Locator tool/syntax in a python script.  I keep getting error as shown in the title of this thread.

Here is my function:

locatorsDir = r'\\SLCISARCGIS10-T\arcgisresources\common\geocode\test'

def createCompositeLocator(locatorsDir):
    #arcpy.env.workspace = locatorsDir
    outLocator = '{}\\CompositePY'.format(locatorsDir)
    addrSF = '{}\\AddressSF'.format(locatorsDir)
    addrSH = '{}AddressSH'.format(locatorsDir)
    centerLines = '{}\\Centerline'.format(locatorsDir)
    parcels = '{}\\Parcels'.format(locatorsDir)
    #locators = '{} AddressSF; {} AddressSH; {} Centerline; {} Parcels'.format(addrSF,addrSH, centerLines,parcels)
    locators = addrSF + ' AddrSF;' + addrSH + ' AddrSH;' + centerLines + ' Centerline;' + parcels + ' Parcels'
    

    
    
    
    fieldMap  = """
                   SingleKey "Key" true true false 100 Text 0 0 ,First,#,
                   \\slcisarcgis10-t\arcgisresources\common\geocode\Test\AddressSF,SingleKey,0,0,
                   \\slcisarcgis10-t\arcgisresources\common\geocode\Test\AddressSH,Street,0,0,
                   \\slcisarcgis10-t\arcgisresources\common\geocode\Test\Centerline,Street,0,0,
                   \\slcisarcgis10-t\arcgisresources\common\geocode\Test\Parcels,SingleKey,0,0
                 """
    arcpy.geocoding.CreateCompositeAddressLocator(locators,fieldMap,"",outLocator)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The contents of FieldMap comes right out of the create composite locator tool history (Pro) or the geoprocessing results (ArcGIS).  The tool executes just fine in either application.  I cannot figure out what/why the error is telling me...

Eric Anderson

Brad Niemand

That should just about do it....
0 Kudos
11 Replies
BradNiemand
Esri Regular Contributor

Joe,

It looks correct to me except maybe in the field mapping you have double quotes around Key where in an example I have it looks like it should be single quotes (maybe even no quotes would work if it is a single word).

i am not a Python guy though so maybe Victor Bhattacharyya can help with this if my suggestions doesn't help.

Brad

0 Kudos
JoeBorgione
MVP Emeritus

Thanks Brad.  Same error with no quotes or single quotes. Is your example available online for us user types?  I've had a composite work before, but not this week....

That should just about do it....
0 Kudos
VictorBhattacharyya
Esri Alum

Hi Joe.

The sample looks good to me other than the selection_criteria parameter. All of my CreateCompositeAddressLocator python snippets do have a selection criteria. 

Here's what it looks like, if you had 2 locators and you gave them names of street_loc and Locator

"street_loc #;Locator #"

So, instead of passing empty string "" as the 3rd parameter to the arcpy call, I would pass, in your case, 

"AddrSF #;AddrSH #;Centerline #;Parcels #"
    

As the string to the arcpy call for the 3rd parameter. Give that a try and let me know how it goes!

Thanks,

Victor

0 Kudos
JoeBorgione
MVP Emeritus

Thanks Victor:

I was thinking (hoping) it was a problem of escaping the slashes through out the unc paths.  That didn't do it; I had tried adding the selectionCriteria variable already.

I did find if I copy all my locators to a mapped drive, ('J:' in my case), escaping the slashes correctly, it works:

J:\\PythonDevelopment\\NewCompositeLocator\\AddressSF.loc AddressSF;J:\\PythonDevelopment\\NewCompositeLocator\\AddressSH.loc AddressSH;J:\\PythonDevelopment\\NewCompositeLocator\\Centerlines.loc Centerlines;J:\\PythonDevelopment\\NewCompositeLocator\\Parcels.loc Parcels


Field Map	

SingleKey "Key" true true false 100 Text 0 0,First,#,
J:\\PythonDevelopment\\NewCompositeLocator\\AddressSF.loc,SingleKey,0,100,
J:\\PythonDevelopment\\NewCompositeLocator\\AddressSH.loc,Street,0,100,
J:\\PythonDevelopment\\NewCompositeLocator\\Centerlines.loc,Street,0,100,
J:\\PythonDevelopment\\NewCompositeLocator\\Parcels.loc,SingleKey,0,100

Is it sensitive to unc paths?

That should just about do it....
0 Kudos
MichaelVolz
Esteemed Contributor

Is a hyphen considered to be a special character and not advisable to use in a file path?

0 Kudos
JoeBorgione
MVP Emeritus

Not sure, Michael.  I'll look at our original scripts.

That should just about do it....
0 Kudos
MichaelVolz
Esteemed Contributor

If the hyphen worked in previous ArcMap versions but is considered to be a special character, ESRI might have tightened up their code to not allow hyphens any more.  In my org I know that a script that you used to work over the network in 10.5.1 and previous, can only be run locally on the server at 10.7.1 as it produces erratic results which is not acceptable in a production environment.

0 Kudos
JoeBorgione
MVP Emeritus

In my org I know that a script that you used to work over the network in 10.5.1 and previous, can only be run locally on the server at 10.7.1 as it produces erratic results which is not acceptable in a production environment.  Worth noting!

I just tried these and both work, so I don't think it's the dash....

arcpy.env.workspace = '\\\\slcisarcgis10-t\\arcgisresources\\common\\geocode\\Test'

arcpy.env.workspace = r'\\SLCISARCGIS10-T\arcgisresources\common\geocode\test'
That should just about do it....
0 Kudos
VictorBhattacharyya
Esri Alum

You could also try setting the arcpy.env.workspace, and then you wouldn't need to use UNC paths, just the name of of the locator in the field mapping.

All of my python tests do have a selection criteria. So I definitely would not leave that parameter blank while you're trying to get it working.

0 Kudos