Data Table to IFeatureDataSet?

608
5
02-01-2011 07:43 AM
AndrewDavis
New Contributor
Hi,

I have a query which brings back a selectionset on a SQL database in C#.  I want to take that table and create a FileGDB featureclass from it in a scratchworkspace.

I am trying to create the FeatureDataSet for the Featureclass from the derived table I have retreived from SQL.

my System.Data.DataTable will not convert to IFeatureDataSet.  If you have any advice it is welcome,

Andrew....
0 Kudos
5 Replies
KyungKim
New Contributor
Hi,

I have a query which brings back a selectionset on a SQL database in C#.  I want to take that table and create a FileGDB featureclass from it in a scratchworkspace.

I am trying to create the FeatureDataSet for the Featureclass from the derived table I have retreived from SQL.

my System.Data.DataTable will not convert to IFeatureDataSet.  If you have any advice it is welcome,

Andrew....


I don't know well, but if you don't mind my comment...  Are you trying to get IFeatureDataset directly from the table?  Probably, I think that you need first get IFeatureClass from the table by using IFeatueDataConverter, and then you get IFeatureDataset from the IFeatureClass.  Did you try this way already?

Kyung
0 Kudos
AndrewDavis
New Contributor
Thanks..  I will try that out this morning...

Andy
0 Kudos
NeilClemmons
Regular Contributor III
"I am trying to create the FeatureDataSet for the Featureclass from the derived table I have retreived from SQL."

I'm not sure what this means.  A feature dataset is a container.  You can't create one "from" a table or feature class.  You simply create a new feature dataset inside the geodatabase and add the feature class to it (a feature dataset cannot contain tables).  The feature dataset can be created by calling IFeatureWorkspace.CreateFeatureDataset.  The feature class you're creating should be created using IFeatureDataset.CreateFeatureClass.  Of course, you don't have to put a feature class inside of a feature dataset.  They can be standalone.  Feature datasets are mainly used to organize related data.  To create the feature class as a standalone class you call IFeatureWorkspace.CreateFeatureClass.
0 Kudos
AndrewDavis
New Contributor
"I am trying to create the FeatureDataSet for the Featureclass from the derived table I have retreived from SQL."

I'm not sure what this means. A feature dataset is a container. You can't create one "from" a table or feature class. You simply create a new feature dataset inside the geodatabase and add the feature class to it (a feature dataset cannot contain tables). The feature dataset can be created by calling IFeatureWorkspace.CreateFeatureDataset. The feature class you're creating should be created using IFeatureDataset.CreateFeatureClass. Of course, you don't have to put a feature class inside of a feature dataset. They can be standalone. Feature datasets are mainly used to organize related data. To create the feature class as a standalone class you call IFeatureWorkspace.CreateFeatureClass.


Yep, found that out quickly this morning.   Your explanation is better than I could've given though.

I want to take a discreet data set from a larger SDE database and programatically impose a selection (DefinitionQuery) on the data inside and put that information into a FileGDB.

I can connect to the DB which I queried to create that original table, and create a SDE FeatureClass, and add it to the map with a DefinitionQuery.

Now I need to export that discreet dataset to a FileGDB.

Andy
0 Kudos
NeilClemmons
Regular Contributor III
Probably the easiest way to do this would be to use the feature class to feature class geoprocessing tool.  You can call this tool through code using the objects in the Geoprocessing library.  This tool will allow you to copy an entire feature class or apply a query filter to copy only a subset.  I believe you'll need to create the target feature class prior to calling the tool but I'm not sure on that.
0 Kudos