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: Â Â Â count += 1 Â Â Â if count == n: Â Â Â Â Â Â Â rows.deleteRow(row) Â Â Â Â Â Â Â count = 0
#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 >= 1: #error check rto make sure you have enough selected features to get an appropriate sample   randomSampleList = radom.sample(fidSetList, int(len(fidSetList) *samplePct)) else:   print "Not enough selected features to constitute a " + str(samplePct * 100) + "% sample!"
arcpy.MakeFeatureLayer(roadsFC, "delete_me", "OBJECTID in (" + str(randomSampleList)[1:-1] + ")") arcpy.DeleteFeatures_Managment("delete_me")
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.