programmatically add feature class to feature dataset

4012
4
Jump to solution
11-26-2013 12:26 AM
Rvan_Rijen
New Contributor II
Hi,

We are using ArcGIS 10.0.

We have several existing feature classes that we want to add to a feature dataset. Of course you can drag and drop the feature classes in the dataset, but our requirements dictate that all changes must be scripted.

Is it possible to use a toolbox to move a feature class into a feature dataset?

I have tried arcpy.Rename_management(r'feature_class', r'feature_dataset\feature_class'). This does not give an error and returns the text <Result 'feature_dataset\feature_class'>, but nothing actually happens. Looks like a bug to me...

Thanks!
Rob
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Rob,

I don't believe this will be possible using Python.  You will most likely need to do this using one of the data transfer methods with ArcObjects:

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000003rp000000

View solution in original post

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
You can import the feature class to the feature dataset as a new name, delete the original feature class, and then rename the feature class in the feature dataset.  Ex:

import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\redlands.gdb"

fc = "Hospitals"
dataset = "test"

arcpy.FeatureClassToFeatureClass_conversion(fc, env.workspace + "\\" + dataset, fc + "_1")
arcpy.Delete_management(fc)
arcpy.Rename_management(fc + "_1", fc)
Rvan_Rijen
New Contributor II
Thanks for your reply Jake!

These feature classes are in an Oracle database and are >25GB in size. Creating a physical copy of the data and would take a lot of space and time.

In my understanding, a feature dataset is merely logical layer in the SDE administration. When we use ArcCatalog to move a feature class into a dataset, the actual Oracle tables are not affected. Only the SDE administration (e.g. gdb_items, gdb_itemrelationships) is changed.

Is it possible to duplicate this ArcCatalog behaviour in Python?

Thanks,
Rob
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Rob,

I don't believe this will be possible using Python.  You will most likely need to do this using one of the data transfer methods with ArcObjects:

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000003rp000000
0 Kudos
Rvan_Rijen
New Contributor II
Thanks Jake!

I'll look into the data transfer methods.

Rob
0 Kudos