Provides access to members that create and open various types of datasets and other workspace level objects.
Description
The IFeatureWorkspaceinterface is used to access and manage datasets that are a key component of a feature based geodatabase; Tables and ObjectClasses, FeatureClasses, FeatureDatasets, and RelationshipClasses. All of the Open methods (such as OpenTable) take a dataset name as input. When working with an enterprise geodatabase, the name may be fully qualified (for example, "database.owner.tablename" or "owner.tablename") using the qualification character appropriate to the underlying database (see ISQLSyntax)). If the input name is not fully qualified, then it is qualified using the currently connected user for the workspace.
When working with geodatabases (personal, file or ArcSDE) the workspace keeps a running object table of instantiated datasets. Multiple calls to open an already instantiated dataset will return a reference to the already instantiated dataset.
When To Use
IFeatureWorkspace is the main interface for creating and opening objects and object classes with a workspace.
Members
Name | Description | |
---|---|---|
CreateFeatureClass | Creates a new standalone feature class under the workspace. | |
CreateFeatureDataset | Creates a new feature dataset. | |
CreateQueryDef | Create a query definition object. | |
CreateRelationshipClass | Creates a new relationship class. | |
CreateTable | Creates a new table. | |
OpenExtensionDataset | Opens an existing extension dataset. | |
OpenFeatureClass | Opens an existing feature class. | |
OpenFeatureDataset | Opens an existing feature dataset. | |
OpenFeatureQuery | Opens a feature dataset containing a single feature class defined by the specified Query. | |
OpenRelationshipClass | Opens an existing relationship class. | |
OpenRelationshipQuery | The table of a relationship join query. | |
OpenTable | Opens an existing table. |
IFeatureWorkspace.CreateFeatureClass Method
Creates a new standalone feature class under the workspace.
Public Function CreateFeatureClass ( _
ByVal Name As String, _
ByVal Fields As IFields, _
ByVal CLSID As UID, _
ByVal EXTCLSID As UID, _
ByVal FeatureType As esriFeatureType, _
ByVal ShapeFieldName As String, _
ByVal ConfigKeyword As String _
) As IFeatureClass
public IFeatureClass CreateFeatureClass (
string Name,
IFields Fields,
UID CLSID,
UID EXTCLSID,
esriFeatureType FeatureType,
string ShapeFieldName,
string ConfigKeyword
);
Errors Returned
FDO_E_CANNOT_CREATE_LOW_PREC_DATASET_IN_HIGH_PREC_DB:Cannot create a low precision dataset in a high precision database.
FDO_E_CANNOT_CREATE_HIGH_PREC_DATASET_IN_LOW_PREC_DB:Cannot create a high precision dataset in a low precision database
Functional License Check
If your application/site is not appropriately licensed, CreateFeatureClass can return an error of FDO_E_NO_SCHEMA_LICENSE.
Remarks
The CreateFeatureClassmethod can be used to create a stand-alone feature class that is not part of a feature dataset. It takes, in addition to all the parameters that CreateTable takes, an esriFeatureType parameter that specifies the category of features to be stored in this feature class (i.e., esriFTSimple, esriFTComplexEdgeFeature) and a shape field name. The shape field name identifies the name of the field in the input fields collection that represents the shape field for the feature class.
The Fields object passed to the Fields parameter should not be an object retrieved from another class. If the new class is going to have the same fields as an existing class, cast the existing class' fields collection to the IClone interface, clone it, and use the cloned fields collection as input for this method.
The GeometryDef object associated with the shape field object must be fully setup with a spatial reference, grid properties, and the geometry type before calling CreateFeatureClass.
The following esriGeometryType enumeration values represent the valid geometry types for a new feature class' GeometryDefobject: esriGeometryPoint, esriGeometryMultipoint, esriGeometryPolyline, esriGeometryPolygon, and esriGeometryMultiPatch.
If the feature class is being created in geodatabase then the fields collection must contain, at a minimum, an Object ID field and a Shape field. The required fields can be obtained from the class description for the type of object you wish to create (see the RequiredFields property on IObjectClassDescription).
The CLSID parameter is used to specify what type of feature will be contained by the class. If a null value is passed in for the CLSID, the geodatabase will return Feature instances from the class. In most cases, this is the desired behavior. If the feature class is used to store custom features, the GUID of the custom feature should be provided. Alternatively, the IClassSchemaEdit interface can be used to change the feature class' CLSID following creation.
The EXTCLSID parameter is used to specify what class will be instantiated as the feature class extension. This object must at least support the IClassExtension interface. If a null value is passed in for the EXTCLSID parameter, the feature class will not have a class extension associated with it. Since class extensions are not required, this is often the desired behavior. If the feature class should have an associated extension, the GUID of the class extension should be provided. Alternatively, the IClassSchemaEdit interface can be used to associate a class extension following creation.
The _configurationKeyword_parameter allows the application to control the physical layout for this table in the underlying RDBMS. For example, in the case of an Oracle database, the configuration keyword controls the tablespace in which the table is created, the initial and next extents, and other properties. The configuration keywords for an ArcSDE instance are set up by the ArcSDE data administrator, and the list of available keywords supported by a workspace may be obtained using the IWorkspaceConfigurationinterface.
If the workspace the feature class will be created in is a pre-9.2 geodatabase, you must ensure the GeometryDef references a low precision spatial reference. 9.1 and earlier versions of the geodatabase only support low precision spatial references, while 9.2 geodatabases require high precision spatial references. Use IControlPrecision2::IsHighPrecision to manage the precision level of the spatial reference used to create the feature class. Use the IGeodatabaseRelease interface to determine the release of the geodatabase.
Developers should be aware that calling this method on a shapefile workspace when a shapefile of the same name already exists will cause the existing shapefile to be deleted. To prevent this, check for the existence of a shapefile prior to calling this method.
Note:Table or feature class names with the following prefixes are not supported:
~ "gdb_"~ "sde_"~ "delta_"
IFeatureWorkspace.CreateFeatureDataset Method
Creates a new feature dataset.
Public Function CreateFeatureDataset ( _
ByVal Name As String, _
ByVal SpatialReference As ISpatialReference _
) As IFeatureDataset
public IFeatureDataset CreateFeatureDataset (
string Name,
ISpatialReference SpatialReference
);
Errors Returned
FDO_E_CANNOT_CREATE_LOW_PREC_DATASET_IN_HIGH_PREC_DB: Cannot create a low precision dataset in a high precision database.
FDO_E_CANNOT_CREATE_HIGH_PREC_DATASET_IN_LOW_PREC_DB: Cannot create a high precision dataset in a low precision database.
Functional License Check
If your application/site is not appropriately licensed, CreateFeatureDataset can return an error of FDO_E_NO_SCHEMA_LICENSE.
Remarks
The CreateFeatureDataset method can be used to create a new FeatureDataset given its name and spatial reference. Methods supported by the returned feature dataset allow creation of feature classes in the feature dataset.
If the workspace the FeatureDataset will be created in is a pre-9.2 Geodatabase, you must ensure the spatial reference is a low precision spatial reference. 9.1 and earlier versions of the Geodatabase only support low precision spatial references, while 9.2 Geodatabases require high precision spatial references. Use IControlPrecision2::IsHighPrecision to manage the precision level of the spatial reference used to create the FeatureDataset. Use the IGeodatabaseRelease interface to determine the release of the geodatabase
IFeatureWorkspace.CreateQueryDef Method
Create a query definition object.
Public Function CreateQueryDef ( _
) As IQueryDef
public IQueryDef CreateQueryDef (
);
Functional License Check
If your application/site is not appropriately licensed, CreateQueryDef can return an error of FDO_E_NO_SCHEMA_LICENSE.
Remarks
The CreateQueryDefmethod can be used to create a new query definition object that can be evaluated by returning a cursor.
With personal geodatabases, QueryDefs do not return newly inserted rows, within an edit session when the QueryDef contains a Where Clause. The edits must be saved and the QueryDef executed outside of the edit session or Search must be used to return the information.
IFeatureWorkspace.CreateRelationshipClass Method
Creates a new relationship class.
Public Function CreateRelationshipClass ( _
ByVal relClassName As String, _
ByVal OriginClass As IObjectClass, _
ByVal DestinationClass As IObjectClass, _
ByVal ForwardLabel As String, _
ByVal BackwardLabel As String, _
ByVal Cardinality As esriRelCardinality, _
ByVal Notification As esriRelNotification, _
ByVal IsComposite As Boolean, _
ByVal IsAttributed As Boolean, _
ByVal relAttrFields As IFields, _
ByVal OriginPrimaryKey As String, _
ByVal destPrimaryKey As String, _
ByVal OriginForeignKey As String, _
ByVal destForeignKey As String _
) As IRelationshipClass
public IRelationshipClass CreateRelationshipClass (
string relClassName,
IObjectClass OriginClass,
IObjectClass DestinationClass,
string ForwardLabel,
string BackwardLabel,
esriRelCardinality Cardinality,
esriRelNotification Notification,
bool IsComposite,
bool IsAttributed,
IFields relAttrFields,
string OriginPrimaryKey,
string destPrimaryKey,
string OriginForeignKey,
string destForeignKey
);
Functional License Check
If your application/site is not appropriately licensed, CreateRelationshipClass can return an error of FDO_E_NO_SCHEMA_LICENSE.
Remarks
The CreateRelationshipClassmethod can be used to create a new stand-alone relationship class that is not part of a feature dataset. The relationship class is implemented as a separate data table whose name is the name of the relationship class if the cardinality is many-to-many or if the relationship class is attributed. The relAttribFields****parameter is optional, and a null value may be passed in for non-attributed relationship classes.
Many-to-many or attributed relationship classes require specification of all four key fields�the OriginPrimaryKey**and the _destPrimaryKey_**parameters are the primary key fields for the origin and destination object classes. The OriginForeignKey**and _destForeignKey_**parameters are the names of the corresponding foreign keys that will be created in the data table representing the relationship class. If the relationship class is one-to-one or one-to-many and not attributed, then the relationship class is implemented as a foreign key field in the destination object class (the OriginForeignKey) that references the primary key field in the origin object class (the OriginPrimaryKey). In this case, the OriginPrimaryKey, the OriginForeignKey, and the destPrimaryKey****must be supplied.
The Fields object passed to the relAttrFields parameter should not be an object retrieved from another class. If the new class is going to have the same fields as an existing class, cast the existing class' fields collection to the IClone interface, clone it, and use the cloned fields collection as input for this method.
IFeatureWorkspace.CreateTable Method
Creates a new table.
Public Function CreateTable ( _
ByVal Name As String, _
ByVal Fields As IFields, _
ByVal CLSID As UID, _
ByVal EXTCLSID As UID, _
ByVal ConfigKeyword As String _
) As ITable
public ITable CreateTable (
string Name,
IFields Fields,
UID CLSID,
UID EXTCLSID,
string ConfigKeyword
);
Functional License Check
If your application/site is not appropriately licensed, CreateTable can return an error of FDO_E_NO_SCHEMA_LICENSE.
Remarks
The CreateTable method can be used to create a new table or object class in the workspace.
The optional CLSID and EXTCLSID parameters allow the calling application to specify the GUIDs for the objects that implement the instance and the class extension behavior for an object class. If no CLSID is passed in, then the resulting table is not registered in the geodatabase object class data dictionary (It will support the IObjectClass interface but will have an ObjectClassID of –1). Valid values for CLSID are esriGeoDatabase.Object or any non-spatial object that extends esriGeoDatabase.Object. CLSID must be set in order to apply a class extension with the EXTCLSID parameter.
The Fields object passed to the Fields parameter should not be an object retrieved from another class. If the new class is going to have the same fields as an existing class, cast the existing class' fields collection to the IClone interface, clone it, and use the cloned fields collection as input for this method.
The optional configurationKeyword parameter allows the application to control the physical layout for this table in the underlying RDBMS. For example, in an Oracle database, the configuration keyword controls the tablespace in which the table is created, the initial and next extents, and other properties. The configuration keywords for an ArcSDE instance are set up by the ArcSDE data administrator, the list of available keywords supported by a workspace may be obtained using the IWorkspaceConfiguration interface.
Note: Table or feature class names with the following prefixes are not supported:
- "gdb_"
- "sde_"
- "delta_"
IFeatureWorkspace.OpenExtensionDataset Method
Opens an existing extension dataset.
Public Function OpenExtensionDataset ( _
ByVal extensionDatasetType As esriDatasetType, _
ByVal extensionDatasetName As String _
) As IDataset
public IDataset OpenExtensionDataset (
esriDatasetType extensionDatasetType,
string extensionDatasetName
);
private void OpenUtilityNetworkwExtentionDataset( IWorkspace workspace, string unName = "UtilityNetwork")
{
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IDataset unDataset = featureWorkspace.OpenExtensionDataset(esriDatasetType.esriDTUtilityNetwork, unName);
}
IFeatureWorkspace.OpenFeatureClass Method
Opens an existing feature class.
Public Function OpenFeatureClass ( _
ByVal Name As String _
) As IFeatureClass
public IFeatureClass OpenFeatureClass (
string Name
);
Remarks
The OpenFeatureClassmethod can be used to open any existing feature class in the workspace given its fully qualified name. Note that every feature class in a geodatabase has a unique fully qualified name, and the OpenFeatureClassmethod can be used to directly open feature classes****that are part of a feature dataset (the feature dataset name does not need to be specified).
Use the IDatabaseConnectionInfo interface to determine the User and Database (if applicable). ISQLSyntax::QualifyTableName can be used to determine the fully qualified name for a feature class. Use the NameExists method on the IWorkspace2 interface to determine if a feature class with the appropriate name exists in a geodatabase.
Opening a feature class that participates in a topology or geometric network will also open all other feature classes participating in the topology or geometric network in memory.
Some examples of how to use the Name parameter of OpenFeatureClassare shown below:For Coverage feature classes:buildings:polygon
For Oracle feature classes (the owner prefix is unnecessary if you are connected as the owner of the feature class):gdb.Buildings
For SQLServer feature classes:
fdo_data.gdb.Buildings
For Informix feature classes:
bladetest2:gdb.Buildings
For VPF feature classes:
ks032193:veg:vgfarea (library:coverage:feature class)
The library name for VPF data is case sensitive and must appear as it is stored in the LAT (Library Attribute Table)
The 4 tables associated with a Topology; T_#_DirtyAreas, T_#_PolyErrors, T_#_LineErrors and T_#_PointErrors cannot be directly edited. For this reason they cannot be opened and will fail with a general Geodatabase error.
IFeatureWorkspace.OpenFeatureDataset Method
Opens an existing feature dataset.
Public Function OpenFeatureDataset ( _
ByVal Name As String _
) As IFeatureDataset
public IFeatureDataset OpenFeatureDataset (
string Name
);
Remarks
The OpenFeatureDatasetmethod can be used to open any existing feature dataset in the workspace given its fully qualified name.
Use the IDatabaseConnectionInfo interface to determine the User and Database (if applicable). ISQLSyntax::QualifyTableName can be used to determine the fully qualified name for a feature dataset.
IFeatureWorkspace.OpenFeatureQuery Method
Opens a feature dataset containing a single feature class defined by the specified Query.
Public Function OpenFeatureQuery ( _
ByVal QueryName As String, _
ByVal QueryDef As IQueryDef _
) As IFeatureDataset
public IFeatureDataset OpenFeatureQuery (
string QueryName,
IQueryDef QueryDef
);
Remarks
The OpenFeatureQuerycan be used to open a virtual feature class whose definition is based on a QueryDef**created using the CreateQueryDefmethod. The QueryDef**can involve multiple tables as long as one of them is a feature class; the resulting virtual feature class can be used to construct a feature layer that can be added to a map. The shape column is required as part of the SubFields parameter of the QueryDef.
IFeatureWorkspace.OpenRelationshipClass Method
Opens an existing relationship class.
Public Function OpenRelationshipClass ( _
ByVal Name As String _
) As IRelationshipClass
public IRelationshipClass OpenRelationshipClass (
string Name
);
Remarks
The OpenRelationshipClassmethod can be used to open any existing relationship class in the workspace given its fully qualified name.
Use the IDatabaseConnectionInfo interface to determine the User and Database (if applicable). ISQLSyntax::QualifyTableName can be used to determine the fully qualified name for a relationship class.
IFeatureWorkspace.OpenRelationshipQuery Method
The table of a relationship join query.
Public Function OpenRelationshipQuery ( _
ByVal relClass As IRelationshipClass, _
ByVal joinForward As Boolean, _
ByVal SrcQueryFilter As IQueryFilter, _
ByVal SrcSelectionSet As ISelectionSet, _
ByVal TargetColumns As String, _
ByVal DoNotPushJoinToDB As Boolean _
) As ITable
public ITable OpenRelationshipQuery (
IRelationshipClass relClass,
bool joinForward,
IQueryFilter SrcQueryFilter,
ISelectionSet SrcSelectionSet,
string TargetColumns,
bool DoNotPushJoinToDB
);
IFeatureWorkspace.OpenTable Method
Opens an existing table.
Public Function OpenTable ( _
ByVal Name As String _
) As ITable
public ITable OpenTable (
string Name
);
Remarks
The OpenTablemethod can be used to open any existing table or object class in the workspace given its fully qualified name. The table object returned will always support the ITableinterface. The returned table object will support additional interfaces depending on the type of table. For example, object classes will additionally support the IObjectClassinterface.
Use the IDatabaseConnectionInfo interface to determine the User and Database (if applicable). ISQLSyntax::QualifyTableName can be used to determine the fully qualified name for a table. Use the NameExists method on the IWorkspace2 interface to determine if a table with the appropriate name exists in a geodatabase.
Some examples of how to use the name parameter of OpenTableare shown below:For Coverage feature classes:cover:feature("stream:arc")
For info tables:cover:feature("stream.aat")
For Oracle tables:gdb.Owners
For SQLServer tables:
fdo_data.gdb.Owners
For Informix tables:
bladetest2:gdb.Owners
The 4 tables associated with a Topology; T_#_DirtyAreas, T_#_PolyErrors, T_#_LineErrors and T_#_PointErrors cannot be directly edited. For this reason they cannot be opened and will fail with a general Geodatabase error.
Classes that implement IFeatureWorkspace
Classes | Description |
---|---|
BimFileWorkspace (esriDataSourcesFile) | Esri BIM File Workspace |
ParquetFileWorkspace (esriDataSourcesFile) | Parquet File Workspace |
SqlWorkspace (esriDataSourcesGDB) | Sql workspace |
Workspace | Workspace Object. |