How To: Access an existing locator connection from a script
Online locators can be accessed through an ArcCatalog GIS server connection. When a connection is created in ArcCatalog, an .ags file is created in the user's Windows login profile. The instructions provided describe how to access an existing locator connection from a Python script.
When a script is run outside of the ArcGIS environment, such as from a command line, batch file, or application, it references a folder in the user profile.
'c:\users\<username>' or 'c:\documents and settings\<username>.'
• Windows Server: %USERPROFILE%\AppData\Roaming\ESRI\ArcCatalog
• Windows 7: %USERPROFILE%\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog
The user profile contains an .ags file, such as 'premiumlocators.ags,' with the connection path and credentials for the service.
• For standard locators: GIS Servers\\arcgisonline\\Locators\\TA_Streets_US.GeocodeServer
The steps below describe how to use the server connection information in a script.
Run a task from a different user profile
Run applications outside of a user profile with no credentials
pathToAGS = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog”
agsName = “premiumtasks” # for an AGS file called premiumtasks.ags
locatorName = “Locators\TA_Address_NA.GeocodeServer"
Locator = os.path.join(pathToAGS, agsName, locatorName)
In this case, the full path would appear as follows.
Obtain the full string for a specific locator
2. Browse to the .ags file on disk. It is displayed as a server connection name in the dialog (for instance, 'arcgis on tasks.arcgisonline.com' if the task has not been renamed or 'premiumtasks' if it has been renamed).
3. Double-click the connection name to view the contents.
4. Browse to the exact locator desired within that connection.
The .ags file can be accessed from anywhere on disk using the syntax given above.