Extract Data - Deleting Empty Feature Classes

5919
5
03-23-2011 04:54 PM
MichaelClarke
New Contributor III
Hi,
When I use the "Extract Data" tool (Distributed Geodatabase toolbar) I get the data I want plus a heap of empty Feature Classes in the target Geodatabase.

Is there a tool that will look at my Geodatabase and delete these empty Feature Classes? I would prefer a tool that would automatically do this over a script, but any suggestions would be good at this stage.

Thanks!
Mick
0 Kudos
5 Replies
MichaelClarke
New Contributor III
*Bump*

Anybody?
0 Kudos
HeatherMcCracken
Esri Contributor
Hi Mick,

Likely what you are seeing is the extract data tools default behavior, which is to also extract any fc's or tables which are related to the data that you are asking to be extracted.  For example, the list of data to be exported expands to include all the data in any feature dataset and any related data.
You can change this behavior by viewing the Advanced panel when going through the Extract Data Wizard.  On one of the panels it will list all the FC's and tables which will be extracted - simply uncheck any of those which you do not want to be extracted.

Does this help?
Thanks,
Heather
0 Kudos
JakeSkinner
Esri Esteemed Contributor
I believe Heather's solution is correct.  Here is a script that you can use to delete empty feature classes just in case:

import arcpy
from arcpy import env

env.workspace = r"C:\Temp\Test.gdb"

listFCs = arcpy.ListFeatureClasses("*")

for fc in listFCs:
    count1 = str(arcpy.GetCount_management(fc))
    if count1 == "0":
        arcpy.Delete_management(fc)

       
You can easily turn this into a tool by changing 'env.workspace' to:

env.workspace = arcpy.GetParameterAsText(0)

Then import the script into ArcToolbox and set an input under the Parameters tab within the Properties.
BenLeslie1
Occasional Contributor III

Can you explain why you need to convert the count into a string?

I'd been trying to make this work for a little while and that was my problem - hadn't converted count into string.

0 Kudos
MichaelClarke
New Contributor III
@ Heather, Thanks for your reply. I do use the 'Advanced' options to deselect any unwanted feature classes. The problem occurs when if the feature classes I deselect were in a feature dataset, I get an empty dataset (there is no way to deselect the dataset). Also if there were no features within the Area of Interest graphic, but I leave the feature class selected as I'm unsure of this, I get the empty feature dataset.
I agree this is the default behaviour, probably due to the tool being related to 'distributed' databases, users may create new features to upload and therefore need all the feature classes they've extracted. So the problem is more related to how I'm using the tool, not the tool itself.:) (I don't intend to upload the data I've extracted)

@ JSkinn3, Thanks for the script! I'll give it a try tomorrow and let you know how I go. I'm a noob at scripting/python so it could be interesting. Doing the training soon, hence the preference for a tool, but if one doesn't exist, it doesn't exist.

Many thanks!
-Mick
0 Kudos