Select to view content in your preferred language

Problem in Deleting Feature Classes in Geo Database

2190
1
04-16-2014 09:02 PM
H_A_D_Padmasiri
Deactivated User
Dear Sir

I wrote a python programme to delete feature classes in a Geo database.
it works, But feature classes are not delete. What is the reason ? and How to correct it?

Thanks

Padmasiri

import arcpy
from arcpy import env
env.workspace = r"J:\Gampaha\51027202\CM51027202.gdb\CM51027202"
FClass_List = ["CNT_Anno", "CNT_Anno_CD", "CNT_PT", "PCL_CT1"]
for FClass in FClass_List:
arcpy.DeleteFeatures_management(FClass)


<Result 'J:\\Gampaha\\51027202\\CM51027202.gdb\\CM51027202\\CNT_Anno'>
<Result 'J:\\Gampaha\\51027202\\CM51027202.gdb\\CM51027202\\CNT_Anno_CD'>
<Result 'J:\\Gampaha\\51027202\\CM51027202.gdb\\CM51027202\\CNT_PT'>
<Result 'J:\\Gampaha\\51027202\\CM51027202.gdb\\CM51027202\\PCL_CT1'>
Tags (2)
0 Kudos
1 Reply
DouglasSands
Deactivated User
Hi Padmasiri,

The problem is that the delete features tool removes the features from a feature class or layer (empties it). This is why the result is the name of the feature class you put into the tool. Because you want to delete the dataset completely, you want to use the delete tool:

import arcpy
from arcpy import env
env.workspace = r"J:\Gampaha\51027202\CM51027202.gdb\CM51027202"
FClass_List = ["CNT_Anno", "CNT_Anno_CD", "CNT_PT", "PCL_CT1"]
for FClass in FClass_List:
    arcpy.Delete_management(FClass)


Also, if you wrap scripts in code tags when posting, it will display a bit cleaner (like the above). Hope this helps!
- Doug
0 Kudos