AnsweredAssumed Answered

arcpy.Geocode won't work inside script

Question asked by v-robcha on Aug 14, 2014
Latest reply on Nov 10, 2014 by brownkj

Hello All,

  • Using ArcGIS 10.2.1 for Desktop on Windows 8.1


I have searched through the forums and couldn't find a resolution to this, though people have experienced similar problems:


I have a fairly simple script that will:

  1. take a user string input (an address)
  2. create a temp table to store the address
  3. geocode address
  4. more processing planned


I have tried:

  • running Geocode Addresses from the toolbox with the same inputs and it works
  • running the following piece of code from the python command line in arcmap work
  • arcpy.GeocodeAddresses_geocoding("C:/Users/v-robcha/Documents/ArcGIS/Default.gdb/GeocodeTemp","GIS Servers/geocoderfromESRI/World.GeocodeServer","SingleLine Address VISIBLE NONE","C:/Users/v-robcha/Documents/ArcGIS/Default.gdb/GeocodeTEMP_GeocodeAddresses_1","STATIC")


But when I try to use that EXACT line (hard coded file paths and all) in a script tool the geocoded results are empty. No matched or unmatched, just zero features. Furthermore, when I try to use variables for the file paths it returns the same result (nothing).


Below is the full script, I am quite frustrated at this point.

# Import arcpy module import arcpy import csv import os arcpy.env.workspace = r"C:/Users/v-robcha/Documents/ArcGIS/Default.gdb" ws = arcpy.env.workspace #address to be geocoded  address = arcpy.GetParameterAsText(0) #geocode service geocoder = r"GIS Servers\geocoderfromESRI\World.GeocodeServer" # dbf template for geocoding dbftemplate = "TemplateGeocode" # geocode output fn GeocodeAddressOut = "GeocodeAddresses_please" # user parameter for facilities (hotels, avis, etc) ## set up list of choices ## FacilitiesLocations = "AvisLocations_All1" # create table to store user input address arcpy.CreateTable_management(ws,"GeocodeTemp",dbftemplate,"#") ifields = ["OBJECTID", "Address"] irow = ["0", address] icur = arcpy.da.InsertCursor("GeocodeTemp", ifields) icur.insertRow(irow) # Process: Geocode Addresses arcpy.GeocodeAddresses_geocoding("GeocodeTemp", geocoder, "SingleLine Address VISIBLE NONE", GeocodeAddressOut, "STATIC")