I want to add an existing feature class to an existing feature dataset. Both the feature class and the dataset have the same coordinate system, I searched over the net but only assistance I found was to create a new feature class in a feature dataset (I tried that and it worked). According my understanding I tried using IDatasetContainer
but it's not working. Here is the code:
IFeatureDataset featureDataset1 = featureWorkspace.OpenFeatureDataset("featureDataset1");
IDataset datasetFcTenActors = fc_tenActors as IDataset; // fc_tenActors is my feature class to add
IDatasetContainer container = featureDataset1 as IDatasetContainer;
container.AddDataset(datasetFcTenActors);
-
@DevdattaTengshe : thanks but I am able to do the same using arcmaps by simply copying the feature class and pasting into the feature dataset. Also there is already a line feature class present in the feature dataset which I created but not copy.Aditya– Aditya2014年01月30日 15:55:57 +00:00Commented Jan 30, 2014 at 15:55
-
It doesn't change when I drag and drop but changes when I copy paste. I want to code the drag and drop into feature dataset.Aditya– Aditya2014年01月30日 16:08:58 +00:00Commented Jan 30, 2014 at 16:08
-
ok.. Got it. I was misunderstanding your question.Devdatta Tengshe– Devdatta Tengshe2014年01月30日 16:10:34 +00:00Commented Jan 30, 2014 at 16:10
-
What do you mean when you say that the code does not work?Devdatta Tengshe– Devdatta Tengshe2014年01月30日 16:13:26 +00:00Commented Jan 30, 2014 at 16:13
-
@DevdattaTengshe : I tried the above code and gave COM exception "Exception from HRESULT: 0x8004022D" on the line - container.AddDataset(datasetFcTenActors);Aditya– Aditya2014年01月30日 16:55:36 +00:00Commented Jan 30, 2014 at 16:55
2 Answers 2
Maybe the IFeatureDataConverter2.ConvertFeatureClass Method does what you need:
It takes a source Featureclass Name and an Output featuredataset Name as Parameter.
The IDatasetContainer
interface lets you move datasets between FeatureDataset
s and Workspaces
—both objects implement the interface. However, It should be used to move datasets between Feature Datasets within a single workspace, but not between workspaces. If you situation doesn't meet this precondition, follow Chris suggestion (IFeatureDataConverter2
). Note that when moving feature classes into a feature dataset, the spatial reference of the source feature class must match the spatial reference of the target feature dataset.
Explore related questions
See similar questions with these tags.