Delete feature class from ArcGIS Pro project

1713
6
Jump to solution
01-21-2020 12:32 AM
RehmSoftware
New Contributor III

Hi,

I have a very simple need: I want to delete a feature class from an ArcGIS Pro project permanently.

arcpy.Delete_management only seems to delete the layer from the map, but not the feature class. How can I delete the feature class permanently? (Apart from arcpy I could also use the ArcGIS Pro SDK, just in case somebody knows a way to do it there)

Thanks in advance

Christian

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

How are you coming to the conclusion that the FC is still there?  If it is the Catalog pane in Pro, you need to hit F5 to refresh the contents of the FGDB.

View solution in original post

0 Kudos
6 Replies
AnttiKajanus
New Contributor III

I think you would get better luck with this question in  sub-space https://community.esri.com/community/developers/gis-developers/python

RehmSoftware
New Contributor III

Thank you, I moved the question to the Python sub-space.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

My guess is that you passed the layer name to Delete and that is why only the layer was deleted.  If you want to delete a feature class, you need to pass the full path to the feature class to Delete so that it knows you are wanting a feature class and not a layer or some other object with the same name removed.

0 Kudos
RehmSoftware
New Contributor III

Thanks for your reply. I tried to specify the full path but I wasn't successful.. maybe I'm missing something. Here's the code I typed into the interactive python prompt in ArcGIS:

arcpy.CreateFeatureclass_management(arcpy.env.workspace, "test_fc", "POLYGON")
<Result 'C:\\Users\\Tom\\Documents\\ArcGIS\\Projects\\Example\\Example.gdb\\test_fc'>

arcpy.Delete_management('C:\\Users\\Tom\\Documents\\ArcGIS\\Projects\\Example\\Example.gdb\\test_fc')
<Result 'true'>

However, the layer in the map is gone.. but the feature class is still present in the Example.gdb. What am I doing wrong?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

How are you coming to the conclusion that the FC is still there?  If it is the Catalog pane in Pro, you need to hit F5 to refresh the contents of the FGDB.

0 Kudos
RehmSoftware
New Contributor III

*facepalm* You're right of course.. I assumed that the Catalog pane would update itself automatically just like everything else does in ArcGIS Pro to reflect changes. But turns out it didn't. Thanks a lot!

0 Kudos