<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic streamline repetitive manual quality control in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/streamline-repetitive-manual-quality-control/m-p/267782#M20626</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, I have the wonderful task of briefly looking over census blocks w/ residential zoning for an Emergency Management project.&amp;nbsp; 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.&amp;nbsp; I also need to keep track of what I’ve already QC’d.&amp;nbsp; Here’s a python trick to streamline the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my “censusBlocks” feature class I’ve added a field for “hasResidentialZoning” and also “QCd”.&amp;nbsp; I render it by category so QCd = 1 is green, and Null is just an outline.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the python window inside ArcMAP, I run the script below.&amp;nbsp; 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.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; &lt;STRONG style="text-decoration: underline;"&gt;&lt;EM&gt;Boo Carpal Tunnel&lt;/EM&gt;&lt;/STRONG&gt;!&amp;nbsp; I can shut the map down and pick up where I left off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;mxd = arcpy.mapping.MapDocument('CURRENT')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;lyr = arcpy.mapping.ListLayers(mxd, "censusBlocks", df)[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;oids = []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;with arcpy.da.SearchCursor("censusBlocks", 'OBJECTID') as c:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for r in c:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oids.append(r[0])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;print len(oids)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;def x():&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = oids.pop()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "OBJECTID = " + str(n) +'AND hasResidentialZone = 1 AND QCd IS NULL'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", where)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(lyr, 'QCd', 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to modify this for similar repetitive tasks I can lend a hand if needed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Happy mundane QC checks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kev&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jan 2016 16:48:24 GMT</pubDate>
    <dc:creator>KevinBell</dc:creator>
    <dc:date>2016-01-28T16:48:24Z</dc:date>
    <item>
      <title>streamline repetitive manual quality control</title>
      <link>https://community.esri.com/t5/python-questions/streamline-repetitive-manual-quality-control/m-p/267782#M20626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, I have the wonderful task of briefly looking over census blocks w/ residential zoning for an Emergency Management project.&amp;nbsp; 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.&amp;nbsp; I also need to keep track of what I’ve already QC’d.&amp;nbsp; Here’s a python trick to streamline the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my “censusBlocks” feature class I’ve added a field for “hasResidentialZoning” and also “QCd”.&amp;nbsp; I render it by category so QCd = 1 is green, and Null is just an outline.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the python window inside ArcMAP, I run the script below.&amp;nbsp; 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.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; &lt;STRONG style="text-decoration: underline;"&gt;&lt;EM&gt;Boo Carpal Tunnel&lt;/EM&gt;&lt;/STRONG&gt;!&amp;nbsp; I can shut the map down and pick up where I left off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;mxd = arcpy.mapping.MapDocument('CURRENT')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;lyr = arcpy.mapping.ListLayers(mxd, "censusBlocks", df)[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;oids = []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;with arcpy.da.SearchCursor("censusBlocks", 'OBJECTID') as c:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for r in c:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oids.append(r[0])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;print len(oids)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;def x():&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = oids.pop()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "OBJECTID = " + str(n) +'AND hasResidentialZone = 1 AND QCd IS NULL'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", where)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(lyr, 'QCd', 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to modify this for similar repetitive tasks I can lend a hand if needed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Happy mundane QC checks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kev&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 16:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/streamline-repetitive-manual-quality-control/m-p/267782#M20626</guid>
      <dc:creator>KevinBell</dc:creator>
      <dc:date>2016-01-28T16:48:24Z</dc:date>
    </item>
  </channel>
</rss>

