<?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: deleting selected features (footprint shapes) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730623#M56677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would you want these shapes randomly selected or would every 10th shape in the selection be fine?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Mar 2012 19:05:59 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2012-03-07T19:05:59Z</dc:date>
    <item>
      <title>deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730622#M56676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ usually I am the person giving answers .. on CityEngine .. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;though I am new to Python coding in ArcGIS, so I'd be happy if anyone could help me with the following issue :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a layer with a few hundred shapes, where I am creating manual selections. based on those selected features, I'd like to delete n% of the selected shapes. e.g. 10% each time I run the script to 'thin out' the data in certain regions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any input welcome .. !&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 19:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730622#M56676</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2012-03-07T19:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730623#M56677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would you want these shapes randomly selected or would every 10th shape in the selection be fine?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 19:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730623#M56677</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-03-07T19:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730624#M56678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hey !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;better randomly, but every nth would already be great.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having the issue with actually getting the list from the selection..&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 19:08:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730624#M56678</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2012-03-07T19:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730625#M56679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This should get you started. Will delete every n row. The cursor will honour selections so just make sure you reference the feature layer you have the selection on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
flayer = #your feature layer with the selection, hardcode name or passed parameter
rows = arcpy.UpdateCursor(flayer)
count = 0
n = 10
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if count == n:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.deleteRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = 0&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Deleting random rows while ensuring 10% is deleted is also possible, but would involve a bit more coding.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730625#M56679</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T07:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730626#M56680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hey !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks a lot for that code, it works so far !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to understand what actually happens here is that all features are actually stored as they were in a geometrical grid and then you delete them based on that grid ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;is it also possible to just use a for loop and (possibly) delete each object based on a probability ? or are list based structures not possible ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thx again so far !&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 20:10:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730626#M56680</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2012-03-07T20:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730627#M56681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This code should give you a random 10% sample of the OBJECTIDs in a feature layer that have a selected set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Warning: Untested
import random, arcpy
samplePct = 0.1
arcpy.MakeFeatureLayer_managment(roadsFC, "roads", "")
arcpy.SelectLayerByAttribute_managment("roads", "NEW_SELECTION", "ROAD_TYPE = 'Highway')
fidSetList = [int(fid) for fid in arcpy.Describe("roads").fidSet.split(";")]
if len(fidSetList) * samplePct &amp;gt;= 1: #error check rto make sure you have enough selected features to get an appropriate sample
&amp;nbsp;&amp;nbsp; randomSampleList = radom.sample(fidSetList, int(len(fidSetList) *samplePct))
else:
&amp;nbsp;&amp;nbsp; print "Not enough selected features to constitute a " + str(samplePct * 100) +&amp;nbsp; "% sample!"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you could delete them like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.MakeFeatureLayer(roadsFC, "delete_me", "OBJECTID in (" + str(randomSampleList)[1:-1] + ")")
arcpy.DeleteFeatures_Managment("delete_me")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or use an update cursor... same thing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:11:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730627#M56681</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T07:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: deleting selected features (footprint shapes)</title>
      <link>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730628#M56682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi Chris !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for that input ! appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll have a look at this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Mar 2012 08:38:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-selected-features-footprint-shapes/m-p/730628#M56682</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2012-03-08T08:38:34Z</dc:date>
    </item>
  </channel>
</rss>

