Select to view content in your preferred language

Geocoding: Error000004 : Could not get the address fields

908
2
06-13-2013 07:49 PM
JulianKatz-Samuels
Emerging Contributor
Hi,

I've been trying to use arcpy to geocode a set of files, but I don't know what input fields to use. If I try to manually geocode a file one at a time, one of my input fields is "Street or Intersection" and another is "City or Placename", but I'm not sure how to put these into arcpy because of the spaces. When I just put them in as below, I get the error as in the subject. How should I refer to these input fields?  Also, notice that I've tried "Address" and "City" instead and these returned the same error.

#Julian Katz-Samuels
#May 1, 2013
#Geocode addresses

import arcpy

parts=range(10)
parts.remove(0)
parts=map(str, parts)

years=["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009"]

Geocoder = r"X:\ebruch\shared\Locator\Street_Addresses_US.loc.xml"

#Check that file exists
try:
   with open(Geocoder): pass
except IOError:
   print 'Oh dear geocoder.'

for i in years:
    for j in parts:
        address_table= r"X:\ebruch\shared\HistoryFile" + i + "_part" + j +".csv"
        geocode_result= r"X:\ebruch\shared\GeocodedHistoryFiles\GeocodedHistoryFiles.gdb\GeocodedHistoryFile" + i + "_part" + j + ".shp"
        try:
           with open(address_table): pass
        except IOError:
           print 'Oh dear address table.'
        arcpy.GeocodeAddresses_geocoding(address_table, Geocoder, "Street or Intersection StreetNumStreetName VISIBLE NONE;City or Placename SRmailCITY VISIBLE NONE;State SRmailSTATE VISIBLE NONE;Zip SRmailZIP VISIBLE NONE", geocode_result, "STATIC")
print "Done!"




Thank you,
Julian
Tags (2)
0 Kudos
2 Replies
T__WayneWhitley
Honored Contributor
...maybe I'm off-base here, but is the geocoder file extension supposed to be '.loc.xml'?
0 Kudos
JulianKatz-Samuels
Emerging Contributor
Hi,

I think that you may be right, but when I change it, python no longer even finds the file... So, I don't know why that is.

#Julian Katz-Samuels
#May 1, 2013
#Geocode addresses

import arcpy
from arcpy import env

parts=range(10)
parts.remove(0)
parts=map(str, parts)

years=["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009"]

env.workspace="X:\ebruch\shared\GeocodedHistoryFiles\GeocodedHistoryFiles.gdb"
address_locator = "X:\ebruch\shared\Locator\Street_Addresses_US"

#Check that file exists
try:
   with open(address_locator): pass
except IOError:
   print 'Oh dear address locator.'

for i in years:
    for j in parts:
        address_table= "X:\ebruch\shared\HistoryFile" + i + "_part" + j +".csv"
        geocode_result= "X:\ebruch\shared\GeocodedHistoryFiles\GeocodedHistoryFiles.gdb\GeocodedHistoryFile" + i + "_part" + j + ".shp"
        try:
           with open(address_table): pass
        except IOError:
           print 'Oh dear address table.'
        arcpy.GeocodeAddresses_geocoding(address_table, address_locator, "Street or Intersection StreetNumStreetName VISIBLE NONE;City or Placename SRmailCITY VISIBLE NONE;State SRmailSTATE VISIBLE NONE;Zip SRmailZIP VISIBLE NONE", geocode_result, "STATIC")
print "Done!"

0 Kudos