KevinBellSLC

streamline repetitive manual quality control

Discussion created by KevinBellSLC on Jan 28, 2016

So, I have the wonderful task of briefly looking over census blocks w/ residential zoning for an Emergency Management project.  I’m building a search atlas w/ data driven pages, so there will be a map for every block, and I need to clean up the weird polygons.  I also need to keep track of what I’ve already QC’d.  Here’s a python trick to streamline the process.

 

In my “censusBlocks” feature class I’ve added a field for “hasResidentialZoning” and also “QCd”.  I render it by category so QCd = 1 is green, and Null is just an outline.

 

In the python window inside ArcMAP, I run the script below.  It builds a list of OID’s where QCd is Null and HasResidentialZoning = 1 and then, inside the python window, when I type “x()” it zooms to the next censusblock and turns it green.  In the python window, if I hit the “up arrow” on my keyboard, it pastes in the previous line “x()” and hitting “enter” repeats the process.

 

It’s one move vs. having to select a row in the table, hit zoom-to, right-click the QCd field, field calculate to 1, then select the next row.  Boo Carpal Tunnel!  I can shut the map down and pick up where I left off.

 

import arcpy

mxd = arcpy.mapping.MapDocument('CURRENT')

df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

lyr = arcpy.mapping.ListLayers(mxd, "censusBlocks", df)[0]

 

oids = []

with arcpy.da.SearchCursor("censusBlocks", 'OBJECTID') as c:

    for r in c:

        oids.append(r[0])

print len(oids)

 

def x():

    n = oids.pop()

    where = "OBJECTID = " + str(n) +'AND hasResidentialZone = 1 AND QCd IS NULL'

    arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", where)

    df.zoomToSelectedFeatures()

    arcpy.CalculateField_management(lyr, 'QCd', 1)

    arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")

 

 

If you need to modify this for similar repetitive tasks I can lend a hand if needed.

 

Happy mundane QC checks!

 

 

Kev

Outcomes