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)
Solved! Go to Solution.
I discovered the answer on github. Hopefully this will help someone else with the same question.
https://github.com/deelesh/batch-geocoding-python
http://proceedings.esri.com/library/userconf/devsummit13/papers/devsummit-183.pdf
I discovered the answer on github. Hopefully this will help someone else with the same question.
https://github.com/deelesh/batch-geocoding-python
http://proceedings.esri.com/library/userconf/devsummit13/papers/devsummit-183.pdf
I tried the github code and I am consistently getting errors with the last function which does the actual geocoding. I have tested and retested and it creates output geodatabase and Arcgis online connection fine(see screenshot). The only thing I have added on the code part is adding my arcgis online credentials.
This is the error I am getting
>>> Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\GIS_Data\geocode\BatchGeocoding.py", line 56, in <module>
output_feature_class)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geocoding.py", line 220, in GeocodeAddresses
raise e
ExecuteError: ERROR 000010: Geocode addresses failed.
Failed to execute (GeocodeAddresses).
>>>
Any ideas?
You can try this tool in ArcGIS Pro, there is also the arcgis Python API you can use in a Jupyter notebook, for example this example.
Thank You Bruce,
I ended up creating a model in Arcmap and exported it as a Python script and it is working so far.