Select to view content in your preferred language

Geocode Table using Esri World Geocode via Python Script

10-28-2020 12:02 PM
Regular Contributor

Is it possible to geocode a table using the Esri World Geocoder in a stand alone script using Pro and the function arcpy.GeocodeAddresses_geocoding?

If I'm in Pro and use this tool, and use the Esri World Geocoder we have as an item in our Portal (with an AGO user credentials stored), I can successfully geocode the table as expected.

If I try writing a stand-alone Python script, it fails every time, and I'm really not sure what I'm doing wrong.

Below is a sample of my code:

# portal variables
portalUrl = '...our AGO for Organizations URL...'
portalUser = '...userName...'
portalPassword = '...userPassword...'

# geocode variables
geocodeTable = '...path to table containing addresses...'
geocodeUrl = r''
geocodeUrl = r'...url to our Portal item referencing the Esri World Geocoder with AGO credentials stored...'
geocodeFieldMap = 'Address SiteAddress;City SiteCity;Region SiteState;Postal SiteZip'
geocodeOutput = '...path to output feature class...'

arcpy.SignInToPortal(portalUrl, portalUser, portalPassword)
arcpy.GeocodeAddresses_geocoding(geocodeTable, geocodeUrl, geocodeFieldMap, geocodeOutput, None, None, None, None)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I seem to always get this error: 

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000005: Could not open the address locator.
Failed to execute (GeocodeAddresses).

I have also tried using arcgis.geocoding.batch_geocode ... but this doesn't preserve any of the other attributes within the table, other than the address information used to locate the point, which is pointless for what we're trying to accomplish.

2 Replies
Regular Contributor


The tool you mentioned works only with local adress locators (.loc) not Geocoding REST Endpoint.

To use the REST enpoint I suggest to use requests library and make regular http calls.




0 Kudos
MVP Regular Contributor

It looks like you can use the function with ESRI World Geocoding Service according to example 4 from that page? I'm basically looking to do the same thing as @mpboyle.

Out of ignorance, I can't figure out what to use for the locator URL. I have ArcGIS Developer account and I'm able to generate an API key, but I don't know enough to be able to utilize it. This is how it looks in the example, but that URL throws a 403.

locator = r""



0 Kudos