POST
|
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)
... View more
10-03-2019
09:03 AM
|
0
|
1
|
759
|
POST
|
Mike, Thanks for passing this along. Several of us have read through the documentation you referenced and we have tried the recommendations, but having clients who want to load ad hoc data keeps us from implementing the recommendations. Being able to control the data inputs is how we operate in most cases, but we really need to support this use case. Not best practice, but a need in our world. Thanks again Chuck
... View more
11-30-2018
01:47 PM
|
1
|
0
|
262
|
POST
|
Mike, Thanks for getting back to me on this. We have users that do not have ArcGIS Online accounts and our agency will not allow them to put their ad hoc data on our servers. They create shape files by extracting our data or from other software packages and need to load these features into our applications to display and query their data. They could use QGIS or some other GIS app, but since our agency has the most complete data respository, they are interested in using our apps for this purpose. We had an old ArcIMS application that allowed them to do this, but the 1000/4000 feature limit of the ArcGIS environment is a set back to say the least. We have been able to improve most functions by moving to the new Esri solutions, but this limitation is not an improvement in our client's eyes. I hope you can pass this along as an enhancement for a much needed future release. Thanks, Chuck
... View more
11-29-2018
02:01 PM
|
1
|
0
|
1685
|
POST
|
Since this discussion began in 2012 and the answer from Esri really hasn't changed over the life of this topic, I would suggest Esri re-examine this issue. In 2012 most mobile devices came with 16 GB of storage and 1 GB of RAM while today 64 GB and 4 GB are the minimums Comparison of smartphones - Wikipedia In 2012 only large cities had access to 4 G cell networks while today over 50% of world population has access to 4 G networks Mobile broadband - Wikipedia . 5 G is now available in some large cities and should be widespread by 2020. Limiting the number of features passed a client device made sense in 2012, but to not keep up with the changes in network speeds and devices, doesn't fit Esri's marketing image. We understand there are other ways to pass maps and data to client devices than to load shape files, geo JSON files or CSVs, but since Esri makes these functions available we need to Esri to keep this functionality current with technological changes. We are looking for Esri to keep up with industry changes by increasing these limitations and if they want to make suggestions to developers for certain devices we would welcome their input. Developers should be able to limit feature throughput based on our client audience not an antiquated technology spec from 5 or 6 years ago. While this is a little bit of a rant, this is meant to be an encouragement to keep a technology many of us depend on current. While Esri's developer resources have been focused on other products, it's time to redirect some efforts in this area. Chuck Buzzard, MS, GISP GIS Supervisor, Spatial Services Section Finance Department, Technology Division 1102 Broadway, Suite 101 Tacoma, WA 98402 253-798-7703 cbuzzar@co.pierce.wa.us
... View more
11-29-2018
08:20 AM
|
6
|
2
|
1685
|
POST
|
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.
... View more
05-09-2011
03:53 PM
|
2
|
20
|
5263
|
Title | Kudos | Posted |
---|---|---|
1 | 11-29-2018 02:01 PM | |
1 | 11-30-2018 01:47 PM | |
6 | 11-29-2018 08:20 AM | |
2 | 05-09-2011 03:53 PM |
Online Status |
Offline
|
Date Last Visited |
12-22-2020
10:38 PM
|