<?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: Best Practices for selecting a feature from a feature class that was just created. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616613#M74224</link>
    <description>&lt;P&gt;it also lets you add it to the map&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;map&lt;/SPAN&gt;.addLayer(&lt;SPAN&gt;Sel_Point&lt;/SPAN&gt;.getOutput(&lt;SPAN&gt;0&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 20 May 2025 19:18:06 GMT</pubDate>
    <dc:creator>GISDepartmentMFM</dc:creator>
    <dc:date>2025-05-20T19:18:06Z</dc:date>
    <item>
      <title>Best Practices for selecting a feature from a feature class that was just created.</title>
      <link>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1615626#M74194</link>
      <description>&lt;P&gt;I'm wondering what's the best practice is 4 selecting features of a feature class that was just created in the same tool.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This code works perfectly fine when I am running it in a notebook in pro. I get the expected amount of features in my output feature class. I presume this works because it adds the feature to my map and is able to select the desired features.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    arcpy.conversion.ExportFeatures(
        in_features=in_features,
        out_features= output_path,
        where_clause="Status = 'Confirmed'",
        use_field_alias_as_name="NOT_USE_ALIAS",
        field_mapping= field_mapping
    )
    arcpy.AddMessage('Exported routes')

    arcpy.management.SelectLayerByLocation(
        in_layer= f"{output_file_name}",
        overlap_type="INTERSECT",
        select_features=f"{feature1}",
        search_distance="5 Meters",
        selection_type="NEW_SELECTION",
        invert_spatial_relationship="NOT_INVERT"
    )
    arcpy.management.DeleteRows(output_file_name)

    arcpy.management.SelectLayerByLocation(
        in_layer= f"{output_file_name}",
        overlap_type="INTERSECT",
        select_features=f"{feature2}",
        search_distance="5 Meters",
        selection_type="NEW_SELECTION",
        invert_spatial_relationship="INVERT"
    )
    arcpy.management.DeleteRows(output_file_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but when I turn this into a tool the output feature class has 0 features in it. I'm guessing this does not work because it cannot select features of a feature class that is not in my map.&lt;BR /&gt;&lt;BR /&gt;I have tried to add the newly created feature class to my map using a couple different methods: &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-05-16 145837.jpg" style="width: 681px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/132441i07FDAFF1BDA27B76/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-05-16 145837.jpg" alt="Screenshot 2025-05-16 145837.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;These return a layer object but the layer is not added to my map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the overall question is: what is the best way to approach making a selection from a feature class that has just been created?&lt;/P&gt;</description>
      <pubDate>Fri, 16 May 2025 19:01:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1615626#M74194</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2025-05-16T19:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for selecting a feature from a feature class that was just created.</title>
      <link>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1615678#M74195</link>
      <description>&lt;P&gt;Use arcpy.MakeFeatureLayer_managment prior to SelectLayerByLocation&lt;/P&gt;&lt;P&gt;Something like this,&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Create selection feature layer (your exact format)
Sel_Point = arcpy.MakeFeatureLayer_management(
    selection_feature, 
    "point_layer", 
    "\"FID\"={}".format(str(fid_value)) #or OID
    
# Perform selection
arcpy.management.SelectLayerByLocation(
    in_layer=output_file_name,
    overlap_type="INTERSECT",
    select_features=Sel_Point,  # Using the variable you created
    search_distance="5 Meters",
    selection_type="NEW_SELECTION",
    invert_spatial_relationship="NOT_INVERT"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 May 2025 21:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1615678#M74195</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-05-16T21:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for selecting a feature from a feature class that was just created.</title>
      <link>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616114#M74210</link>
      <description>&lt;P class=""&gt;I noticed that you assigned the result of arcpy.MakeFeatureLayer_management to a variable named Sel_Point.&lt;/P&gt;&lt;P class=""&gt;Is it considered best practice to store the output of a tool in a variable like this? Does assigning it to a variable improve the tool’s performance or is it mainly for readability and convenience?&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 17:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616114#M74210</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2025-05-19T17:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for selecting a feature from a feature class that was just created.</title>
      <link>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616125#M74211</link>
      <description>&lt;P&gt;Yes, it is best practice. It would be more for readability than anything, in my opinion.&amp;nbsp; it does nothing for performance that I am aware of.&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 18:03:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616125#M74211</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-05-19T18:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for selecting a feature from a feature class that was just created.</title>
      <link>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616613#M74224</link>
      <description>&lt;P&gt;it also lets you add it to the map&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;map&lt;/SPAN&gt;.addLayer(&lt;SPAN&gt;Sel_Point&lt;/SPAN&gt;.getOutput(&lt;SPAN&gt;0&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 May 2025 19:18:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/best-practices-for-selecting-a-feature-from-a/m-p/1616613#M74224</guid>
      <dc:creator>GISDepartmentMFM</dc:creator>
      <dc:date>2025-05-20T19:18:06Z</dc:date>
    </item>
  </channel>
</rss>

