+ Reply to Thread
Results 1 to 3 of 3

Thread: How to delete all featuresclasses in a FeatureDataset using ArcPy??

  1. #1
    Joshua Vickrey
    Join Date
    Apr 2010
    Posts
    239
    Points
    0
    Answers Provided
    0


    0

    Default How to delete all featuresclasses in a FeatureDataset using ArcPy??

    Does anyone have any sample code that will delete all featuresclasses in a featuredataset using arcpy? Many thanks for any help.

    Regards,

  2. #2
    Brad Posthumus
    Join Date
    Apr 2010
    Posts
    66
    Points
    1
    Answers Provided
    0


    0

    Default Re: How to delete all featuresclasses in a FeatureDataset using ArcPy??

    1. A feature dataset is also a workspace, so set your feature dataset as the environment workspace.
    2. Iterate through each feature class in the workspace and delete it.

    I don't have ArcGIS 10.0 but in 9.3 it looks like this:

    Code:
    import arcgisscripting
    gp = arcgisscripting.create(9.3)
    gp.workspace = r"C:\workspace\fileGeodatabase.gdb\featureDataset"
    for objFeatureClass in gp.listfeatureclasses():
        gp.delete(objFeatureClass)
    Try this in 10:

    Code:
    import arcpy
    arcpy.env.workspace = r"C:\Temp\fileGeodatabase.gdb\featureDataset"
    for objFeatureClass in arcpy.ListFeatureClasses():
        arcpy.Delete_management(objFeatureClass)

  3. #3
    Joshua Vickrey
    Join Date
    Apr 2010
    Posts
    239
    Points
    0
    Answers Provided
    0


    0

    Default Re: How to delete all featuresclasses in a FeatureDataset using ArcPy??

    Quote Originally Posted by bposthumus View Post
    1. A feature dataset is also a workspace, so set your feature dataset as the environment workspace.
    2. Iterate through each feature class in the workspace and delete it.

    I don't have ArcGIS 10.0 but in 9.3 it looks like this:

    Code:
    import arcgisscripting
    gp = arcgisscripting.create(9.3)
    gp.workspace = r"C:\workspace\fileGeodatabase.gdb\featureDataset"
    for objFeatureClass in gp.listfeatureclasses():
        gp.delete(objFeatureClass)
    Try this in 10:

    Code:
    import arcpy
    arcpy.env.workspace = r"C:\Temp\fileGeodatabase.gdb\featureDataset"
    for objFeatureClass in arcpy.ListFeatureClasses():
        arcpy.Delete_management(objFeatureClass)
    many thanks Brad

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts