<?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 Selectbylocation and CopyFeatures via Arcpy in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070677#M42282</link>
    <description>&lt;P&gt;Hello everyone, I am having trouble when trying to automate the process of select-by-location and copy-features in python. My codes looks like below: The logic seems to be right but once it runs, it runs forever which definitely exceeds the time I ran in Arcpro. Any ideas would be appreciated, thank you!&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;env.workspace = "D:/Backup/shapefile/NE_validation"&lt;BR /&gt;outworkspace = "D:/Backup/shapefile/NE_validation"&lt;BR /&gt;NEEEfishnet = "D:/Backup/shapefile/NE_validation/NE_validation.gdb/NEEE_NewEngland_fishnet"&lt;/P&gt;&lt;P&gt;shplist = arcpy.ListFeatureClasses("*Point*")&lt;BR /&gt;for shp in shplist:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # select by location&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.management.SelectLayerByLocation(NEEEfishnet, "INTERSECT", shp, None, "NEW_SELECTION", "NOT_INVERT")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # export selected features (use copy features tool)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; outfeature = outworkspace + "/" + NEEEfishnet[52:75] + shp[37:40] + ".shp"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.management.CopyFeatures(NEEEfishnet, outfeature, '', None, None, None)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # clear selection&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.SelectLayerByAttribute_management(NEEEfishnet, "CLEAR_SELECTION")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update: I change the code to adopt two more functions: make feature layer and save layer to file. The code runs but it does not produce shapefile that is openable. The error message says below. I am going to stop updating, and maybe someone someday will find a solution to this problem...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZoeChen_0-1624471881198.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16712iCB715567C8199EE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ZoeChen_0-1624471881198.png" alt="ZoeChen_0-1624471881198.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 18:12:43 GMT</pubDate>
    <dc:creator>ZoeChen</dc:creator>
    <dc:date>2021-06-23T18:12:43Z</dc:date>
    <item>
      <title>Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070677#M42282</link>
      <description>&lt;P&gt;Hello everyone, I am having trouble when trying to automate the process of select-by-location and copy-features in python. My codes looks like below: The logic seems to be right but once it runs, it runs forever which definitely exceeds the time I ran in Arcpro. Any ideas would be appreciated, thank you!&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;env.workspace = "D:/Backup/shapefile/NE_validation"&lt;BR /&gt;outworkspace = "D:/Backup/shapefile/NE_validation"&lt;BR /&gt;NEEEfishnet = "D:/Backup/shapefile/NE_validation/NE_validation.gdb/NEEE_NewEngland_fishnet"&lt;/P&gt;&lt;P&gt;shplist = arcpy.ListFeatureClasses("*Point*")&lt;BR /&gt;for shp in shplist:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # select by location&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.management.SelectLayerByLocation(NEEEfishnet, "INTERSECT", shp, None, "NEW_SELECTION", "NOT_INVERT")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # export selected features (use copy features tool)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; outfeature = outworkspace + "/" + NEEEfishnet[52:75] + shp[37:40] + ".shp"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.management.CopyFeatures(NEEEfishnet, outfeature, '', None, None, None)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # clear selection&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.SelectLayerByAttribute_management(NEEEfishnet, "CLEAR_SELECTION")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update: I change the code to adopt two more functions: make feature layer and save layer to file. The code runs but it does not produce shapefile that is openable. The error message says below. I am going to stop updating, and maybe someone someday will find a solution to this problem...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZoeChen_0-1624471881198.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16712iCB715567C8199EE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ZoeChen_0-1624471881198.png" alt="ZoeChen_0-1624471881198.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 18:12:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070677#M42282</guid>
      <dc:creator>ZoeChen</dc:creator>
      <dc:date>2021-06-23T18:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070685#M42284</link>
      <description>&lt;P&gt;&lt;EM&gt;it runs forever which definitely exceeds the time I ran in Arcpro&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;does it produce output though?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:12:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070685#M42284</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-21T20:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070721#M42287</link>
      <description>&lt;P&gt;definitely add some print statements to try and track what's going on, I would also separate the directories that your outputs are going into as it's asking for issues.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 21:12:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070721#M42287</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-06-21T21:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070739#M42289</link>
      <description>&lt;P&gt;Thanks, Dan, it does not produce any output.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 22:14:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070739#M42289</guid>
      <dc:creator>ZoeChen</dc:creator>
      <dc:date>2021-06-21T22:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070740#M42290</link>
      <description>&lt;P&gt;Thanks, David.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 22:15:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070740#M42290</guid>
      <dc:creator>ZoeChen</dc:creator>
      <dc:date>2021-06-21T22:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070961#M42319</link>
      <description>&lt;P&gt;Selections don't apply to data sets, they apply to layers or views.&amp;nbsp; Although you can now pass a data set directly to a Select Layer tool (personally, I disagreed with this change when Esri made it a couple years back), the selection isn't being made directly on the data set.&amp;nbsp; Instead, when a data set is passed directly to a Select Layer tool, a layer or view is created behind the scenes and the selection is placed on it.&amp;nbsp; With your code, you are not retrieving the auto-generated layer.&lt;/P&gt;&lt;P&gt;I still personally think it is best practice to create a layer first and then pass it to Select Layer tools.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 14:15:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1070961#M42319</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-06-22T14:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Selectbylocation and CopyFeatures via Arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1071296#M42343</link>
      <description>&lt;P&gt;Wow, thanks for this answer Joshua! It really cleared my puzzles&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":clapping_hands:"&gt;👏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 23:32:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/selectbylocation-and-copyfeatures-via-arcpy/m-p/1071296#M42343</guid>
      <dc:creator>ZoeChen</dc:creator>
      <dc:date>2021-06-22T23:32:12Z</dc:date>
    </item>
  </channel>
</rss>

