AnsweredAssumed Answered

How to Batch Geocode with ArcGIS Online using Python?

Question asked by tjohnsto on Apr 21, 2015
Latest reply on Jan 24, 2018 by kundalay1

I am trying to figure out how to batch geocode a table of addresses using the ArcGIS Online World Geocoder using Python.  I have an enterprise account. I don't get any errors when I run my script. The result is a point FeatureClass with all the input records but they all have a null shape so nothing displays on a map.  Here is my python code:

import arcpy

from arcpy import env

 

env.workspace = "C:/TestData/Geocode.gdb"

 

try:

  arcpy.SignInToPortal_server("<my arcgis online enterprise userid>", "<my password>", "http://www.arcgis.com/")

 

  in_table = r"MYTABLE"

 

  # ArcGIS Online Locator found in ArcCatalog

  locator = r"Ready-To-Use Services/Geocoding/World.GeocodeServer"

 

  out_table = r"GEOCODE_RESULTS"

 

  fields = r"Address Address;City City;Region State;Postal Zip"

 

  arcpy.GeocodeAddresses_geocoding(in_table, locator, fields, out_table, "STATIC")

except Exception as e:

  print e.message

  arcpy.AddError(e.message)

Outcomes