<?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 can a geometry object be used with select layers by location? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822184#M2837</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to use Select Layers By Location tool in Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a polygon feature class that I would like to iterate though each feature and do a select layers by location in order to get a list of layers that each polygon intersects with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I use a search cursor to iterate through the polygons and pass the geometry to&amp;nbsp;&lt;SPAN&gt;Select Layers By Location as the select_features parameter?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;extents = sys.argv[&lt;SPAN style="color: #1750eb;"&gt;1&lt;/SPAN&gt;]
#polygon shapefile containing 4 polygons&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #0033b3;"&gt;try&lt;/SPAN&gt;:
    arcpy.env.workspace = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"C:\Dataset.gdb"
&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #8c8c8c;"&gt;#get extents spatial reference
&lt;/SPAN&gt;&lt;SPAN style="color: #8c8c8c;"&gt;    &lt;/SPAN&gt;ex_sp = arcpy.Describe(extents).spatialReference

    fcs = arcpy.ListFeatureClasses()
    &lt;SPAN style="color: #0033b3;"&gt;with &lt;/SPAN&gt;da.SearchCursor(extents,[&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"SHAPE@"&lt;/SPAN&gt;]) &lt;SPAN style="color: #0033b3;"&gt;as &lt;/SPAN&gt;scursor:
        &lt;SPAN style="color: #0033b3;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #0033b3;"&gt;in &lt;/SPAN&gt;scursor:
            boundary = row[&lt;SPAN style="color: #1750eb;"&gt;0&lt;/SPAN&gt;]
&lt;SPAN style="color: #8c8c8c;"&gt;             &lt;/SPAN&gt;Output_Layer_Names, Count = arcpy.management.SelectLayerByLocation(&lt;SPAN style="color: #660099;"&gt;in_layer&lt;/SPAN&gt;=fcs, &lt;SPAN style="color: #660099;"&gt;overlap_type&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"INTERSECT"&lt;/SPAN&gt;, 
&lt;SPAN style="color: #660099;"&gt;                 select_features&lt;/SPAN&gt;=boundary, &lt;SPAN style="color: #660099;"&gt;search_distance&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #660099;"&gt;selection_type&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;,
&lt;SPAN style="color: #660099;"&gt;                 invert_spatial_relationship&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"NOT_INVERT"&lt;/SPAN&gt;)
            &lt;SPAN style="color: #000080;"&gt;print&lt;/SPAN&gt;(Output_Layer_Names,Count)
&lt;SPAN style="color: #0033b3;"&gt;except&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help is appreciated&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Arthur&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:46:17 GMT</pubDate>
    <dc:creator>ArthurAbbott1</dc:creator>
    <dc:date>2021-12-12T09:46:17Z</dc:date>
    <item>
      <title>can a geometry object be used with select layers by location?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822184#M2837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to use Select Layers By Location tool in Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a polygon feature class that I would like to iterate though each feature and do a select layers by location in order to get a list of layers that each polygon intersects with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I use a search cursor to iterate through the polygons and pass the geometry to&amp;nbsp;&lt;SPAN&gt;Select Layers By Location as the select_features parameter?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;extents = sys.argv[&lt;SPAN style="color: #1750eb;"&gt;1&lt;/SPAN&gt;]
#polygon shapefile containing 4 polygons&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #0033b3;"&gt;try&lt;/SPAN&gt;:
    arcpy.env.workspace = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"C:\Dataset.gdb"
&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #8c8c8c;"&gt;#get extents spatial reference
&lt;/SPAN&gt;&lt;SPAN style="color: #8c8c8c;"&gt;    &lt;/SPAN&gt;ex_sp = arcpy.Describe(extents).spatialReference

    fcs = arcpy.ListFeatureClasses()
    &lt;SPAN style="color: #0033b3;"&gt;with &lt;/SPAN&gt;da.SearchCursor(extents,[&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"SHAPE@"&lt;/SPAN&gt;]) &lt;SPAN style="color: #0033b3;"&gt;as &lt;/SPAN&gt;scursor:
        &lt;SPAN style="color: #0033b3;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #0033b3;"&gt;in &lt;/SPAN&gt;scursor:
            boundary = row[&lt;SPAN style="color: #1750eb;"&gt;0&lt;/SPAN&gt;]
&lt;SPAN style="color: #8c8c8c;"&gt;             &lt;/SPAN&gt;Output_Layer_Names, Count = arcpy.management.SelectLayerByLocation(&lt;SPAN style="color: #660099;"&gt;in_layer&lt;/SPAN&gt;=fcs, &lt;SPAN style="color: #660099;"&gt;overlap_type&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"INTERSECT"&lt;/SPAN&gt;, 
&lt;SPAN style="color: #660099;"&gt;                 select_features&lt;/SPAN&gt;=boundary, &lt;SPAN style="color: #660099;"&gt;search_distance&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #660099;"&gt;selection_type&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;,
&lt;SPAN style="color: #660099;"&gt;                 invert_spatial_relationship&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"NOT_INVERT"&lt;/SPAN&gt;)
            &lt;SPAN style="color: #000080;"&gt;print&lt;/SPAN&gt;(Output_Layer_Names,Count)
&lt;SPAN style="color: #0033b3;"&gt;except&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help is appreciated&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Arthur&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822184#M2837</guid>
      <dc:creator>ArthurAbbott1</dc:creator>
      <dc:date>2021-12-12T09:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: can a geometry object be used with select layers by location?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822185#M2838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what trackback error did you get when you ran it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Oct 2020 19:32:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822185#M2838</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-10-02T19:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: can a geometry object be used with select layers by location?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822186#M2839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;too many values to unpack (expected 2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also get the same error if I try creating a new polygon object and passing that in&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Oct 2020 19:42:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822186#M2839</guid>
      <dc:creator>ArthurAbbott1</dc:creator>
      <dc:date>2020-10-02T19:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: can a geometry object be used with select layers by location?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822187#M2840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE style="color: #080808; background-color: #ffffff; border: 0px; font-size: 9.8pt;"&gt;fcs = arcpy.ListFeatureClasses()&lt;/PRE&gt;&lt;P&gt;then this&lt;/P&gt;&lt;PRE style="color: #080808; background-color: #ffffff; border: 0px; font-size: 9.8pt;"&gt;.... SelectLayerByLocation(&lt;SPAN style="color: #660099; border: 0px; font-weight: inherit; font-size: 13.0667px;"&gt;in_layer&lt;/SPAN&gt;=fcs....,&lt;/PRE&gt;&lt;P&gt;how many featureclasses are there? perhaps you want the first? slice with ....ListFeatureClasses()[0] perhaps.&lt;/P&gt;&lt;P&gt;It would be easier to reference with code formatting&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and if you dump the try-except block, you will still get real error messages&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also the help topic still says layers are required.&amp;nbsp; You can do geometry intersections using arcpy directly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Oct 2020 20:03:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822187#M2840</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-10-02T20:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: can a geometry object be used with select layers by location?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822188#M2841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your issue is with this:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;Output_Layer_Names&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You are trying to unpack the Result object's outputs, but you haven't given the correct number of variables to unpack into.&amp;nbsp; The following should work:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;_&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Output_Layer_Names&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&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, 03 Oct 2020 13:48:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822188#M2841</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-10-03T13:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: can a geometry object be used with select layers by location?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822189#M2842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yup, that did it.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Oct 2020 19:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-a-geometry-object-be-used-with-select-layers/m-p/822189#M2842</guid>
      <dc:creator>ArthurAbbott1</dc:creator>
      <dc:date>2020-10-06T19:55:45Z</dc:date>
    </item>
  </channel>
</rss>

