<?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 SelectLayerbyLocation nested in SearchCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330759#M25751</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am getting an error when I try and run this code, but can't figure out why. Is there something I am missing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;resultCoT = 'A'
with &lt;/SPAN&gt;arcpy.da.SearchCursor(inputpoints&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'*'&lt;/SPAN&gt;) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;pointList:
    &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;point &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;pointList:
&lt;SPAN style="color: #6897bb;"&gt;        &lt;/SPAN&gt;countTest = arcpy.SelectLayerByLocation_management(inputlines&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"INTERSECT"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;point&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;)
        &lt;SPAN style="color: #cc7832;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(countTest&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'*'&lt;/SPAN&gt;) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;lineList:
             &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;line &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;linelist:
                 &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;line[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;] == &lt;SPAN style="color: #6a8759;"&gt;'PROPERTY'&lt;/SPAN&gt;:
                     count = count + &lt;SPAN style="color: #6897bb;"&gt;1
&lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;        &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;count == &lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;:
&lt;SPAN style="color: #808080;"&gt;            &lt;/SPAN&gt;resultCoT = &lt;SPAN style="color: #6a8759;"&gt;'B'
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(resultCoT)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I get at the SelectLayerByLocation tool line is:&lt;/P&gt;&lt;P&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shows you how little I know. . .&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:39:43 GMT</pubDate>
    <dc:creator>QuangTruong</dc:creator>
    <dc:date>2021-12-11T15:39:43Z</dc:date>
    <item>
      <title>SelectLayerbyLocation nested in SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330759#M25751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am getting an error when I try and run this code, but can't figure out why. Is there something I am missing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;resultCoT = 'A'
with &lt;/SPAN&gt;arcpy.da.SearchCursor(inputpoints&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'*'&lt;/SPAN&gt;) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;pointList:
    &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;point &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;pointList:
&lt;SPAN style="color: #6897bb;"&gt;        &lt;/SPAN&gt;countTest = arcpy.SelectLayerByLocation_management(inputlines&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"INTERSECT"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;point&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;)
        &lt;SPAN style="color: #cc7832;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(countTest&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'*'&lt;/SPAN&gt;) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;lineList:
             &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;line &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;linelist:
                 &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;line[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;] == &lt;SPAN style="color: #6a8759;"&gt;'PROPERTY'&lt;/SPAN&gt;:
                     count = count + &lt;SPAN style="color: #6897bb;"&gt;1
&lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;        &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;count == &lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;:
&lt;SPAN style="color: #808080;"&gt;            &lt;/SPAN&gt;resultCoT = &lt;SPAN style="color: #6a8759;"&gt;'B'
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(resultCoT)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I get at the SelectLayerByLocation tool line is:&lt;/P&gt;&lt;P&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shows you how little I know. . .&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330759#M25751</guid>
      <dc:creator>QuangTruong</dc:creator>
      <dc:date>2021-12-11T15:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerbyLocation nested in SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330760#M25752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;'point' isn't a feature layer it looks to be a row in a cursor&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-location.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/select-layer-by-location.htm"&gt;Select Layer By Location—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2020 19:56:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330760#M25752</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-01-21T19:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerbyLocation nested in SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330761#M25753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I am starting to see.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So a row is not a feature layer, and therefore can't be passed into the SelectLayerByLocation too. What can I do to test each point in a feature layer like I want to?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2020 19:59:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330761#M25753</guid>
      <dc:creator>QuangTruong</dc:creator>
      <dc:date>2020-01-21T19:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerbyLocation nested in SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330762#M25754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can pass a single geometry, like a point, to Select Layer By Location.&amp;nbsp; Looking at your code, I am guessing the issue is more with the fact that you are passing a Python tuple instead of an ArcPy geometry object.&amp;nbsp; Additionally, you are using "*" to define the fields, which means all fields and not just geometry.&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;resultCoT &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'A'&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;inputpoints&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SHAPE@'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; pointList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; point&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; pointList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# important to have comma after point variable for tuple unpacking&lt;/SPAN&gt;
        countTest &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByLocation_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;inputlines&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"INTERSECT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; point&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;countTest&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'*'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; lineList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
             &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; line &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; linelist&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; line&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'PROPERTY'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                     count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; count &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; count &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            resultCoT &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'B'&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;resultCoT&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330762#M25754</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T15:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerbyLocation nested in SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330763#M25755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that appears to be the issue. I assumed that by specifying the fields as '*', all fields and geometry would be passed in.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to make the code snippet work by specifically passing through the 'SHAPE@' field. The revised code&amp;nbsp;as you wrote it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you both so much.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:19:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330763#M25755</guid>
      <dc:creator>QuangTruong</dc:creator>
      <dc:date>2020-01-21T20:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerbyLocation nested in SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330764#M25756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The asterisk/wildcard for fields will return geometry information but not a complete ArcPy Geometry object; instead, a tuple of the geometry's centroid is returned.&amp;nbsp; If you want a full-blown ArcPy Geometry object, you need to specify SHAPE@&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2020 21:46:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbylocation-nested-in-searchcursor/m-p/330764#M25756</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-01-21T21:46:01Z</dc:date>
    </item>
  </channel>
</rss>

