<?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: Run script against selected features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203193#M65330</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Assets IS a feature class in a File GDB. Is there a way to run the selection on the FC?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2022 12:10:34 GMT</pubDate>
    <dc:creator>GaryBarden</dc:creator>
    <dc:date>2022-08-16T12:10:34Z</dc:date>
    <item>
      <title>Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1202965#M65320</link>
      <description>&lt;P&gt;I feel like I'm missing something simple here. All I want to do is select a subset from a layer based on an attribute and then do a spatial join of just the subset to a polygon layer.&lt;/P&gt;&lt;P&gt;Script works fine, but it's executing the spatial join against the entire layer, not just the selected records.&lt;/P&gt;&lt;P&gt;# Execute Select&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(asset, "NEW_SELECTION", '"COORDINATE_VALID_DATE" = CURRENT_DATE' )&lt;/P&gt;&lt;P&gt;#Execute Spatial Join&lt;BR /&gt;arcpy.SpatialJoin_analysis(asset, polygonLayer01, "asset_join_poly01", "JOIN_ONE_TO_MANY", "KEEP_COMMON", "", "INTERSECT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 17:31:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1202965#M65320</guid>
      <dc:creator>GaryBarden</dc:creator>
      <dc:date>2022-08-15T17:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1202979#M65322</link>
      <description>&lt;P&gt;Try making the select function into a variable, then passing that into the spatial join.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Execute Select
asset_S = arcpy.management.SelectLayerByAttribute(asset, "NEW_SELECTION", '"COORDINATE_VALID_DATE" = CURRENT_DATE' )

#Execute Spatial Join
arcpy.SpatialJoin_analysis(asset_S, polygonLayer01, "asset_join_poly01", "JOIN_ONE_TO_MANY", "KEEP_COMMON", "", "INTERSECT")

 &lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 Aug 2022 17:58:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1202979#M65322</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2022-08-15T17:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203028#M65324</link>
      <description>&lt;P&gt;got this error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;---------------------------------------------------------------------------&lt;/SPAN&gt;
&lt;SPAN class=""&gt;ExecuteError&lt;/SPAN&gt;                              Traceback (most recent call last)
In  &lt;SPAN class=""&gt;[9]&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;20&lt;/SPAN&gt;:    arcpy.SpatialJoin_analysis(asset_sel, polygonLayer01, &lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;asset_join_poly01&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;JOIN_ONE_TO_MANY&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;KEEP_COMMON&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;INTERSECT&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;)

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\analysis.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;SpatialJoin&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;793&lt;/SPAN&gt;:   &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; e

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\analysis.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;SpatialJoin&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;790&lt;/SPAN&gt;:   retval = convertArcObjectToPythonObject(gp.SpatialJoin_analysis(*gp_fixargs((target_features, join_features, out_feature_class, join_operation, join_type, field_mapping, match_option, search_radius, distance_field_name), &lt;SPAN class=""&gt;True&lt;/SPAN&gt;)))

File &lt;SPAN class=""&gt;C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py&lt;/SPAN&gt;, in &lt;SPAN class=""&gt;&amp;lt;lambda&amp;gt;&lt;/SPAN&gt;:
Line &lt;SPAN class=""&gt;512&lt;/SPAN&gt;:   &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;lambda&lt;/SPAN&gt; *args: val(*gp_fixargs(args, &lt;SPAN class=""&gt;True&lt;/SPAN&gt;))

&lt;SPAN class=""&gt;ExecuteError&lt;/SPAN&gt;: Failed to execute. Parameters are not valid.
ERROR 000732: Target Features: Dataset GIS_ASSET_DETAIL_Layer17 does not exist or is not supported
Failed to execute (SpatialJoin).

&lt;SPAN class=""&gt;---------------------------------------------------------------------------&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;In&amp;nbsp;[&amp;nbsp;]:&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN&gt;​&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 15 Aug 2022 19:50:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203028#M65324</guid>
      <dc:creator>GaryBarden</dc:creator>
      <dc:date>2022-08-15T19:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203151#M65329</link>
      <description>&lt;P&gt;Maybe asset is actually a feature class, not a layer? Selection doesn't work on feature classes.&lt;/P&gt;&lt;P&gt;If that's not it, you should probably post the whole script, so that we can see what's going on before the two lines you posted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To post code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1660635913390.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48701iBA1D161B608D9630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1660635913390.png" alt="JohannesLindner_0-1660635913390.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1660635928900.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48702i11D0BE03D062B345/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1660635928900.png" alt="JohannesLindner_1-1660635928900.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 07:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203151#M65329</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-16T07:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203193#M65330</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Assets IS a feature class in a File GDB. Is there a way to run the selection on the FC?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 12:10:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203193#M65330</guid>
      <dc:creator>GaryBarden</dc:creator>
      <dc:date>2022-08-16T12:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203202#M65331</link>
      <description>&lt;LI-CODE lang="python"&gt;# you can turn asset into a layer:
asset_layer = arcpy.management.MakeFeatureLayer(asset, "asset_layer")
# and then you can call the selection on the layer.


# But, much easier: MakeFeatureLayer takes an optional SQL where clause. So:
asset_layer = arcpy.management.MakeFeatureLayer(asset, "asset_layer", '"COORDINATE_VALID_DATE" = CURRENT_DATE' )
arcpy.SpatialJoin_analysis(asset_layer, polygonLayer01, "asset_join_poly01", "JOIN_ONE_TO_MANY", "KEEP_COMMON", "", "INTERSECT")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 12:34:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203202#M65331</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-16T12:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Run script against selected features</title>
      <link>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203219#M65334</link>
      <description>&lt;P&gt;THANK YOU&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 13:09:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-script-against-selected-features/m-p/1203219#M65334</guid>
      <dc:creator>GaryBarden</dc:creator>
      <dc:date>2022-08-16T13:09:24Z</dc:date>
    </item>
  </channel>
</rss>

