<?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 Re: Update Cursor Tool Returing Error in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673190#M22366</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't have an answer about the cursor problem, but in looking at your task, it seems that you don't need cursors at all -- you could overlay the buffers and the parcel features using &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Spatial_Join/00080000000q000000/"&gt;Spatial Join&lt;/A&gt;&lt;SPAN&gt;, Intersect, or Identity.&amp;nbsp; Spatial Join might be the most direct way -- it will give you a Join_Count attribute which would be the number of buffers that intersect a parcel. And it would be lighting fast compared to select by location for each individual parcel.&amp;nbsp; For an example to get started, see &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2012/10/12/comparingoverlaytools/"&gt;this blog post&lt;/A&gt;&lt;SPAN&gt; and scroll down to the section on Spatial Join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Target features = parcels&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Join features = buffers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Join operation = JOIN_ONE_TO_MANY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Match Option = (you have a choice here)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]If you want buffers that just touch the boundary of a parcel to count, use INTERSECT[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]If the buffer has to cross into a parcel, use WITHIN_A_DISTANCE with a small distance.&amp;nbsp; The blog explains this.[/INDENT]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Mar 2013 17:35:44 GMT</pubDate>
    <dc:creator>DaleHoneycutt</dc:creator>
    <dc:date>2013-03-28T17:35:44Z</dc:date>
    <item>
      <title>Update Cursor Tool Returing Error</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673189#M22365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've written a tool that loops through a parcel file, counts how many buffers intersect a parcel record within that file than updates an attribute field in the parcel layer with this number. The tool runs fine until it gets to the final record in the parcel layer then I get an error message that says&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;type 'exceptions.NameError'&amp;gt;: name 'line' is not defined Failed to execute (RCW 3 Mile).&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I open up the layers attribute table, all the fields have been correctly updated so I don't understand why this error is occurring. Since the tool is part of a larger model I need to understand why this is happening sot the model can proceed forward.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also tried running the tool independently (outside of modelbuilder) with the same results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the code in the tool:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; #Select out each parcel record one by one and evalauate how many cluster buffers intersect with that parcel. #Update Parcel Attribute Table field three_mi with the # of buffers that intersect that parcel&amp;nbsp; SelectedParcelsFL=arcpy.GetParameterAsText(0) CbuffersFL=arcpy.GetParameterAsText(1)&amp;nbsp; #make sure that no records are currently selected in either slected parclesFL or cBuffersFL arcpy.AddMessage("Clearing selected parcel selections\n") arcpy.SelectLayerByAttribute_management(SelectedParcelsFL,"CLEAR_SELECTION") arcpy.AddMessage("Clearing selected buffer selections\n") arcpy.SelectLayerByAttribute_management(CbuffersFL,"CLEAR_SELECTION")&amp;nbsp; #Now begin 3-mile disperal buffer count print "updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel" arcpy.AddMessage("updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel\n")&amp;nbsp; for parcel in range(0,1092): &amp;nbsp;&amp;nbsp;&amp;nbsp; FID = "FID=%s" % (parcel) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(SelectedParcelsFL,"NEW_SELECTION",FID) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(CbuffersFL,"INTERSECT",SelectedParcelsFL) &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferCount = int(arcpy.GetCount_management(CbuffersFL).getOutput(0)) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(FID)+" has "+str(bufferCount)+" RCW 3-mile dispersal buffers that intersect with it.")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #Update the three_mi field&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; uc=arcpy.UpdateCursor(SelectedParcelsFL) &amp;nbsp;&amp;nbsp;&amp;nbsp; for line in uc: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line.three_mi = bufferCount &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uc.updateRow(line) #Actually changes the table values to buffer count &amp;nbsp;&amp;nbsp;&amp;nbsp; del line, uc &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(SelectedParcelsFL,"CLEAR_SELECTION") print "updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel COMPLETED" arcpy.AddMessage("updating parcels table with the number of 3-mile RCW dispersal buffers that intersect each parcel COMPLETED")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 16:56:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673189#M22365</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2013-03-28T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor Tool Returing Error</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673190#M22366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't have an answer about the cursor problem, but in looking at your task, it seems that you don't need cursors at all -- you could overlay the buffers and the parcel features using &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Spatial_Join/00080000000q000000/"&gt;Spatial Join&lt;/A&gt;&lt;SPAN&gt;, Intersect, or Identity.&amp;nbsp; Spatial Join might be the most direct way -- it will give you a Join_Count attribute which would be the number of buffers that intersect a parcel. And it would be lighting fast compared to select by location for each individual parcel.&amp;nbsp; For an example to get started, see &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2012/10/12/comparingoverlaytools/"&gt;this blog post&lt;/A&gt;&lt;SPAN&gt; and scroll down to the section on Spatial Join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Target features = parcels&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Join features = buffers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Join operation = JOIN_ONE_TO_MANY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Match Option = (you have a choice here)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]If you want buffers that just touch the boundary of a parcel to count, use INTERSECT[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]If the buffer has to cross into a parcel, use WITHIN_A_DISTANCE with a small distance.&amp;nbsp; The blog explains this.[/INDENT]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 17:35:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673190#M22366</guid>
      <dc:creator>DaleHoneycutt</dc:creator>
      <dc:date>2013-03-28T17:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor Tool Returing Error</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673191#M22367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your cursor is working fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, you then try to delete something that no longer exists, to wit: line&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if you call each row in the cursor line ( for line in uc: )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;then the cursor stops when line is no more&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;trying to then delete line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;will cause an error: line is already gone.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;just delete the cursor: uc&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I aggree though, that Spatial Join is likely a better option.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 18:15:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673191#M22367</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2013-03-28T18:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor Tool Returing Error</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673192#M22368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;mdenil - &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; You're correct - my range statement was off - it needed to be one less. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 18:22:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/update-cursor-tool-returing-error/m-p/673192#M22368</guid>
      <dc:creator>RachelAlbritton1</dc:creator>
      <dc:date>2013-03-28T18:22:42Z</dc:date>
    </item>
  </channel>
</rss>

