<?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 Cursor and Select by Location in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294292#M10239</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;I have a cursor cycling through several polygon features.&amp;nbsp; Would like to pass the current cursor entry to the Select by Location tool, to select a series of lines contained by the polygons.&amp;nbsp; I am getting an error stating the Select by Location tool is not working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;Is my syntax correct?&amp;nbsp; In the for loop, I defined for "Cup_row in C_update"; do I just pass "Cup_row" as the input to the "SelectLayerByLocation_management" tool&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "A2" exception is displaying "Object: Error in executing tool"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for Cup_row in C_update:

&amp;nbsp;&amp;nbsp;&amp;nbsp; C_count+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalest = Cup_row[0] 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalmoe = Cup_row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_pairid&amp;nbsp;&amp;nbsp; = Cup_row[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_subpairs = Cup_row[3]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_OX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[4]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_OY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[5]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_DX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[6]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_DY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[7]

&amp;nbsp;&amp;nbsp;&amp;nbsp; #initial values
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalest = 0.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalmoe = 0.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_pairid = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; C_pairlist = []&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(p_er):print "A1"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Select Subpairs containted by corridor---##
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(Cup_row, "COMPLETELY_CONTAINS", P_paths, "", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as A2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(A2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "A2 "+ str(A2)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:09:09 GMT</pubDate>
    <dc:creator>MichaelKowalczyk</dc:creator>
    <dc:date>2021-12-11T14:09:09Z</dc:date>
    <item>
      <title>Cursor and Select by Location</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294292#M10239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;I have a cursor cycling through several polygon features.&amp;nbsp; Would like to pass the current cursor entry to the Select by Location tool, to select a series of lines contained by the polygons.&amp;nbsp; I am getting an error stating the Select by Location tool is not working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;Is my syntax correct?&amp;nbsp; In the for loop, I defined for "Cup_row in C_update"; do I just pass "Cup_row" as the input to the "SelectLayerByLocation_management" tool&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "A2" exception is displaying "Object: Error in executing tool"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for Cup_row in C_update:

&amp;nbsp;&amp;nbsp;&amp;nbsp; C_count+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalest = Cup_row[0] 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalmoe = Cup_row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_pairid&amp;nbsp;&amp;nbsp; = Cup_row[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_subpairs = Cup_row[3]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_OX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[4]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_OY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[5]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_DX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[6]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_DY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[7]

&amp;nbsp;&amp;nbsp;&amp;nbsp; #initial values
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalest = 0.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalmoe = 0.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_pairid = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; C_pairlist = []&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(p_er):print "A1"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Select Subpairs containted by corridor---##
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(Cup_row, "COMPLETELY_CONTAINS", P_paths, "", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as A2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(A2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "A2 "+ str(A2)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:09:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294292#M10239</guid>
      <dc:creator>MichaelKowalczyk</dc:creator>
      <dc:date>2021-12-11T14:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cursor and Select by Location</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294293#M10240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, you can't pass a tuple (the "row") to the &lt;SPAN style="color: #3d3d3d;"&gt;Select by Location tool. You should be able to pass a geometry though. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;And if I understand what you're trying to do correctly, you have your select from and select by features in the wrong order.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;with arcpy.da.SearchCursor(fc, ["SHAPE@", "totalest", ..., "DY"]) as C_update:

&amp;nbsp;&amp;nbsp;&amp;nbsp; for Cup_row in C_update:&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C_count+=1&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_shape = Cup_row[0]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_totalest = Cup_row[1]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cup_DY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cup_row[8]&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(P_paths, "COMPLETELY_CONTAINS", Cup_shape, "", "NEW_SELECTION") &lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:09:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294293#M10240</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T14:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cursor and Select by Location</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294294#M10241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! switching the positions and passing the geometry fixed this immediate error!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt; arcpy.SelectLayerByLocation_management(P_paths, &lt;SPAN class="string"&gt;"COMPLETELY_CONTAINS", Cup_shape, "&lt;SPAN class="string"&gt;", "&lt;/SPAN&gt;NEW_SELECTION") &amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 21:32:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/cursor-and-select-by-location/m-p/294294#M10241</guid>
      <dc:creator>MichaelKowalczyk</dc:creator>
      <dc:date>2016-02-06T21:32:46Z</dc:date>
    </item>
  </channel>
</rss>

