Arcpy Delete Features

835
4
06-09-2023 01:37 AM
DirkThuynsma
New Contributor II

Hi, 

I have a python script running in pycharm which selects features and then deletes them. 

The following line gives an error: arcpy.management.DeleteFeatures(Select_2)

The error is as follow: arcgisscripting.ExecuteError: ERROR 160236: The operation is not supported by this implementation.
Failed to execute (DeleteFeatures)

Would appreciate help to solve this error 

Thanks

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor

Hi @DirkThuynsma ,

Can you post a snippet of your code?

Usually, I create a feature layer with the query to select features, and then execute the DeleteFeatures_management on the feature layer.  Ex:

 

arcpy.MakeFeatureLayer_management(r"C:\temp\data.gdb\parcels", "parcels_lyr", "LandUse = 'RES'")
arcpy.DeleteFeatures_management("parcels_lyr")
0 Kudos
DirkThuynsma
New Contributor II

Hi Jake, 

Thanks for the reply. 

Here is the code relevant to the problem. 

#selectbylocation
Select_2 = arcpy.management.SelectLayerByLocation(Seed_Inspection_Pool, "WITHIN", Select_Attribute, None, "NEW_SELECTION")

#deletefeatures
delete = arcpy.management.DeleteFeatures(Select_2)
print("Deleted Pools in Layer")

If needed I can post the complete script. 

The script did work perfectly well until recently when I got this error. 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

What type of layer (i.e. feature class, shapefile) are you performing the selection on.  If it's an Enterprise Geodatabase feature class, is the feature class registered as versioned?

0 Kudos
DuncanHornby
MVP Notable Contributor

Select_2 is a result object, so meaningless in the context of deleting features. If you look at the help file on the Delete Features tool, what does it take as input for the only parameter it takes? Not a result object but a Feature Layer. You need to understand what the parameter section of the help file is tell you. So to delete the features selected by the SelectlayerByLocation tool you need to feed in the layer which in your code is Seed_Inspection_Pool.  Before you run the delete tool you should always check the number of selected is what you expect.