Address Error Checking

5365
20
05-09-2011 03:53 PM
CharlesBuzzard
New Contributor II
In ArcInfo Workstation there is a tool called AddressErrors which checks a street layer with address attributes for a collection of possible errors.  This tool generates an info table that can be related back to the street layer and helps identfy issues that can cause problems during geocoding.  Errors like address range overlaps, even/odd side flips, segment direction flips and a few other errors are identified.

  For those ArcGIS users that support 911 dispatch centers, these tools are a huge help.  The ESRI Seattle Office wrote a python script that could to do similar error checking, but it was very slow and could only process about 5000 segments at a time.

  If you need similar tools or think that it could be helpful, please add to this thread.  We really need ESRI to write this with ArcObjects and optimize it for production sized datasets.
Tags (2)
20 Replies
BruceHarold
Esri Regular Contributor

Joe you had fish.

0 Kudos
JoeBorgione
MVP Emeritus

That should just about do it....
0 Kudos
SuhanLi
New Contributor

I am struggling for my address error issue during Geoprocessing and I am working on the book, Python Scripting for ArcGIS, by Paul Zandbergen. When I found this python script sample in the book, I assume that I saw the dawn from the horizon 

This is a very useful tool.

Regards,

0 Kudos
SuhanLi
New Contributor

From the link that Kory provided, Bruce actually uploaded it two years ago...

Eat more fish!

Regards,

0 Kudos
KoryKramer
Esri Community Moderator

I believe the current link would be https://www.arcgis.com/home/item.html?id=d34959c8f11940c08143440e7fcf585e  but like Bruce said, the script may not work at current releases...

There is not an idea for this right now as far as I can tell on ArcGIS Ideas

0 Kudos
SuhanLi
New Contributor

This helps!

Thanks!

0 Kudos
JoeBorgione
MVP Emeritus
Charles, Joe

Please see here:

http://resources.arcgis.com/gallery/file/geocoding/details?entryID=1A290038-1422-2418-88FC-098400376...

Regards


Nice!  thanks Bruce!
That should just about do it....
0 Kudos
GarriGrossi
New Contributor
So I've downloaded the script, and added the included toolbox to ArcMap. The variable dialogue opens and I fill in the required fields. Upon running the script, I get the error 'Script associated with this toolbox does not exist.'

After a bit of help-thyself searching I found a solution may be the 'relative paths' option, which I checked and ran. With the same problem.
Then I un-checked it and ran the tool. Same error.

Is there something I'm missing? Can I load the script into Model Builder?

Garri
0 Kudos
ToddLusk
New Contributor III

I think you have to check the "relative paths" option then "reload" the script so that the tool picks up on the new relative path.

0 Kudos
CharlesBuzzard
New Contributor II

Try the following script.  Save the text as addressCheck.py; open in idle; change the local variables as neede and run the script.  If you send me an email, I'll send you the script since it looks like all the indents have been stripped.  Good luck

Chuck.Buzzard@PierceCountyWA.gov

# This Python script searches a GIS roads feature class and
# codes an error field depending on a series of address errors
# Addressing rules:
# Road segments must point in direction of increasing house numbers (FLIP)
# Even and Odd sides of street must remain consistant (EVENODD)
# From range value must be smaller that To Range value (FROMTO)
# Ranges can not overlap from one segment to another (OVRLAP)
# A check but not an error would be a missing street segment (GAP)
# Errors checked for are
# Even Odd Flips (EVENODD)
# Overlap in the range (OVRLAP)
# FromTo flip in address range (FROMTO)
# Flip of underlying segments (FLIP)
# Alerts are coded
# Gaps in the network (GAP)
#Dependencies:
# Requires ArcGIS Desktop Advanced License
# Requires standard python 2.7 libraries and ESRI's arcpy library
#Notes:
# Review Local variable section and modify as needed
#Author:
# Chuck Buzzard
#Updates:
# 6/2011;4/2014;9/2016
import sys, os, shutil, time, arcpy
def prepWksp(wksp,wkdb):
 if os.path.exists(wksp+wkdb):
 arcpy.Delete_management(wksp+wkdb)
 arcpy.CreateFileGDB_management(wksp, wkdb)
def hideShowFlds(srclyr,fldLst):
 srcFlds = arcpy.ListFields(srclyr)
 fldinfo = arcpy.FieldInfo()
 for fld in srcFlds:
 if fld.name in fldLst:
 #print fld.name
 fldinfo.addField(fld.name, fld.name, "VISIBLE", "")
 else:
 fldinfo.addField(fld.name, fld.name, "HIDDEN", "")
def print2Log(logTxt,logLoc):
 temp = sys.stdout 
 sys.stdout = open(logLoc,'a') 
 print(logTxt+os.linesep) 
 sys.stdout.close() 
 sys.stdout = temp
#Set Local Variables:
wsLog = "C:\\wkspace\\addr\\logs\\addrerr.log"
wsTrg = "C:\\wkspace\\addr\\"
wsSrc = ""
dbSrc = "\\\\data\\TransportationGDB.gdb\\"
dbTNm = "Staging.gdb"
dbTrg = wsTrg+dbTNm
fcRds = "Roads"
flRds = ["OBJECTID","Shape","LFROM","LTO","RFROM","RTO","PREDIR","NAME","TYPE","DIR","FULLNAME","LZIP","RZIP","LCITY","RCITY","MAPCLASS"]
print "Start Address Error Check: ("+time.ctime()+")"
print2Log("Start Address Error Check: ("+time.ctime()+")",wsLog)
#Prep Target Workspace:
prepWksp(wsTrg,dbTNm)
# Set Geoprocessing environments:
arcpy.env.scratchWorkspace = dbTrg
arcpy.env.workspace = dbTrg
arcpy.env.overwriteOutput = True
#Copy Production Data To Work Area:
arcpy.CopyFeatures_management(dbSrc+fcRds,fcRds)
print "#Prepare Data For Processing:"
print2Log("Prepare Data For Processing:",wsLog)
arcpy.MakeFeatureLayer_management(fcRds,fcRds+"_lyr")
hideShowFlds(fcRds+"_lyr",flRds)
#Code Address Errors
print "Make Nodes: ("+time.ctime()+")"
arcpy.AddField_management(fcRds+"_lyr","sX","LONG")
arcpy.AddField_management(fcRds+"_lyr","sY","LONG")
arcpy.AddField_management(fcRds+"_lyr","FNODE","TEXT",13)
arcpy.CalculateField_management(fcRds+"_lyr","sX","!SHAPE.FIRSTPOINT!.split()[0]","PYTHON")
arcpy.CalculateField_management(fcRds+"_lyr","sY","!SHAPE.FIRSTPOINT!.split()[1]","PYTHON")
arcpy.CalculateField_management(fcRds+"_lyr","FNODE","str(!sX!)+str(!sY!)","PYTHON")
arcpy.AddField_management(fcRds+"_lyr","eX","LONG")
arcpy.AddField_management(fcRds+"_lyr","eY","LONG")
arcpy.AddField_management(fcRds+"_lyr","TNODE","TEXT",13)
arcpy.CalculateField_management(fcRds+"_lyr","eX","!SHAPE.LASTPOINT!.split()[0]","PYTHON")
arcpy.CalculateField_management(fcRds+"_lyr","eY","!SHAPE.LASTPOINT!.split()[1]","PYTHON")
arcpy.CalculateField_management(fcRds+"_lyr","TNODE","str(!eX!)+str(!eY!)","PYTHON")
arcpy.AddField_management(fcRds+"_lyr","ADDERR","TEXT",50)
arcpy.Sort_management(fcRds+"_lyr","cadRoadsLSort",[["LCITY","ASCENDING"],["FULLNAME","ASCENDING"],["LFROM","ASCENDING"]])
print "Code Leftside: ("+time.ctime()+")"
fc="cadRoadsLSort"
flds = ('FNODE','TNODE','LCITY','FULLNAME','LFROM','LTO','ADDERR')
fn = ""
tn = ""
nm = ""
ct = ""
fh = -1
th = -1
er = ""
cnt = 0
with arcpy.da.UpdateCursor(fc,flds) as cursor:
 for row in cursor:
 if ((row[2] == ct) and (row[3] == nm)):
 if (row[4]>row[5]):
 er=str(er)+"FROMTO"
 if (row[4]<=th):
 er=str(er)+"OVERLAP"
 if ((row[4]%2==0 and fh%2!=0) or (row[4]%2!=0 and fh%2==0)):
 er=str(er)+"EVENODD"
 if (row[1]==tn):
 er=str(er)+"FLIP"
 if (row[0]!=tn):
 er=str(er)+"GAP"
 row[6]=str(er)
 fn=row[0]
 tn=row[1]
 ct=row[2]
 nm=row[3]
 fh=row[4]
 th=row[5]
 cursor.updateRow(row)
 er=""
 else :
 fn=row[0]
 tn=row[1]
 ct=row[2]
 nm=row[3]
 fh=row[4]
 th=row[5]
 er=""
print "Code Rightside: ("+time.ctime()+")"
arcpy.Sort_management("cadRoadsLSort","cadRoadsRSort",[["RCITY","ASCENDING"],["FULLNAME","ASCENDING"],["RFROM","ASCENDING"]])
fc="cadRoadsRSort"
flds = ('FNODE','TNODE','RCITY','FULLNAME','RFROM','RTO','ADDERR')
fn = ""
tn = ""
nm = ""
ct = ""
fh = -1
th = -1
er = ""
with arcpy.da.UpdateCursor(fc,flds) as cursor:
 for row in cursor:
 if ((row[2] == ct) and (row[3] == nm)):
 if (row[4]>row[5]):
 er=str(er)+"FROMTO"
 if (row[4]<=th):
 er=str(er)+"OVERLAP"
 if ((row[4]%2==0 and fh%2!=0) or (row[4]%2!=0 and fh%2==0)):
 er=str(er)+"EVENODD"
 if (row[1]==tn):
 er=str(er)+"FLIP"
 if (row[0]!=tn):
 er=str(er)+"GAP"
 row[6]=str(er)
 fn=row[0]
 tn=row[1]
 ct=row[2]
 nm=row[3]
 fh=row[4]
 th=row[5]
 cursor.updateRow(row)
 er=""
 else :
 fn=row[0]
 tn=row[1]
 ct=row[2]
 nm=row[3]
 fh=row[4]
 th=row[5]
 er=""
print "End Address Error Check: ("+time.ctime()+")"
print2Log("End Address Error Check: ("+time.ctime()+")",wsLog)
0 Kudos