AnsweredAssumed Answered

Python Script Reverse Geocoding Fails

Question asked by buehlerd on Sep 12, 2016
Latest reply on Jan 20, 2017 by buehlerd

My intent is to reverse geocode points, and assign them their nearest address.  I have:

  • A master point feature class
    • Which will ultimately need the address populated in a field
  • A "master script" that calculates a bunch of fields on the master point feature class
    • I would like to ultimately add a section that joins the reverse geocoded addresses, calculates the appropriate address field on the master, and removes the join and deletes all the scratch data
    • The master script is pretty quick as to minimize down time, and would like to keep it that way

 

My initial standalone script to reverse geocode took entirely to long to do as it was always reverse coding all the points, and as this points will increase it will eventually take longer.  So, I thought lets only select from the master point feature class, export those out, reverse geocode the selection, and then join the master feature class to do the join and field calculation.

 

However, the reverse geocoding keeps crashing.  In PyScripter I get an "exceptions.EOFError:[Errno 10054] An existing connection was forcibly closed by the remote host" error. and just running the script cause python to crash.

 

It does the first part correctly, which is exports out the features with missing addresses, but then crashes on the reverse geocoding part.  Below is the code I have thus far.  What am I doing wrong?  Am I missing something? Do I need to clean up some variables?

 

# import modules
import arcpy


# Set workspaces
scratchWorkspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb'

selectExport = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9716.gdb\GeoReporting'
missingAddresses = "Match_Addr"

sql = """{} is NULL""".format(missingAddresses)

print "Export Only missing Addresses"
raw_input("Press enter to continue ;)")

# Select concerns that have missing addresses and send them to a scratch workspace for geocoding
arcpy.FeatureClassToFeatureClass_conversion(selectExport, scratchWorkspace, "NoAddresses", sql)

print "Export Successful"
print "Are You Ready to Start Reverse Geocoding?"
raw_input("Press enter to continue ;)")

# Start edit session
edit = arcpy.da.Editor(scratchWorkspace)
edit.startEditing(False, True)
edit.startOperation()

#Additional Variables for reverse geocoding

needsAddress = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\NoAddresses'
address_locator = r'C:/ESRITest/GeoReportingSystem/Testing9116/ActiveOnlyAddresses_CreateAd'
outfc = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\NearestAddress2'

# Reverse Geocode the missing addresses that were selected from the main concern features

arcpy.ReverseGeocode_geocoding(needsAddress, address_locator, outfc, address_type="ADDRESS", search_distance="100 Meters")

print "Reverse Geocode Successful. Would you like to Exit?"


# Close edit session
edit.stopOperation()
edit.stopEditing(True)

raw_input("Press enter to exit ;)")

Outcomes