Python Script Reverse Geocoding Fails

1830
8
Jump to solution
09-12-2016 08:13 AM
DavidBuehler
Occasional Contributor III

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 ;)")
0 Kudos
1 Solution

Accepted Solutions
DavidBuehler
Occasional Contributor III

Ok, after several months of trouble shooting and tech support, I think we have a winner.  When the script would run via idle, pyscripter, the task scheduler, etc. it was trying to use the 32 bit-version not the 64 bit-version.  It blows up with the 32 bit-version, but is perfectly ok with the 64 bit-version.  All I did was reconstitute the script and set it to use the 64 bit-version in the task scheduler and it works.

I will post more if anyone wants to know more.

View solution in original post

0 Kudos
8 Replies
BruceHarold
Esri Regular Contributor
0 Kudos
DavidBuehler
Occasional Contributor III

Hi Bruce,

I do not think that will be an option for me.  We would like to use our own GeoCoder as to not consume a bunch of credits.  I appreciate the suggestion.

David.

0 Kudos
DavidBuehler
Occasional Contributor III

After looking at into this further.  The script produces a geocoded result, but crashes before line 48 "print "Reverse Geocode Successful", and does not delete the unneeded scratch export. Is there a better way of doing what I trying to do?  Is something corrupted?  I am at a loss.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

To see if it is related to the edit session, what if you try the workflow outside of an edit session?

0 Kudos
DavidBuehler
Occasional Contributor III

Well I have done a few things.  I have run the geoprocessing tool both in ArcMap and ArcCatalog using the same parameters minus the export.  I used NoAddresses in Scratch, and used the same locator, same output with no problems.  I then spelled it all out in the python window in ArcMap and ArcCatalog and crash. I do not know if it is a 10.3.1 thing or what. So what I have determined thus far is that it is a script thing, as the geoprocessing tool worked just fine. 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Even if you were doing something wrong with the script, which I am not saying you are, the application shouldn't crash.  I would contact Esri Support because something needs to be addressed.

0 Kudos
DavidBuehler
Occasional Contributor III

I was hoping I would not have to, but it looks like that is going to be the answer.

0 Kudos
DavidBuehler
Occasional Contributor III

Ok, after several months of trouble shooting and tech support, I think we have a winner.  When the script would run via idle, pyscripter, the task scheduler, etc. it was trying to use the 32 bit-version not the 64 bit-version.  It blows up with the 32 bit-version, but is perfectly ok with the 64 bit-version.  All I did was reconstitute the script and set it to use the 64 bit-version in the task scheduler and it works.

I will post more if anyone wants to know more.

0 Kudos