IFeatureClass Interface

Provides access to members that control the behavior and properties of a feature class.

When To Use

The IFeatureClassinterface is the main interface for getting and setting properties of a feature class. For example, use the IFeatureClass interface to get the type of feature class, get a count of features that satisfy some query, or create a new feature in the feature class. The IFeatureClass interface inherits from the IObjectClass interface.

Members

Name Description
Method AddField Adds a field to this object class.
Method AddIndex Adds an index to this object class.
Read-only property AliasName The alias name of the object class.
Read-only property AreaField The geometry area field.
Read-only property CLSID The GUID for the COM Class (CoClass) corresponding to instances of this object class.
Method CreateFeature Create a new feature, with a system assigned object ID and null property values.
Method CreateFeatureBuffer Create a feature buffer that can be used with an insert cursor.
Method DeleteField Deletes a field from this object class.
Method DeleteIndex Deletes an index from this object class.
Read-only property EXTCLSID The GUID for the COM Class (CoClass) corresponding to the class extension for this object class.
Read-only property Extension The extension for this object class.
Read-only property ExtensionProperties The extension properties for this object class.
Read-only property FeatureClassID The unique ID for the Feature Class.
Method FeatureCount The number of features selected by the specified query.
Read-only property FeatureDataset The feature dataset that contains the feature class.
Read-only property FeatureType The type of features in this feature class.
Read-only property Fields The fields collection for this object class.
Method FindField The index of the field with the specified name.
Method GetFeature Get the feature with the specified object ID.
Method GetFeatures Get a cursor of Rows given a set of object ids.
Read-only property HasOID Indicates if the class has an object identity (OID) field.
Read-only property Indexes The indexes collection for this object class.
Method Insert Returns a cursor that can be used to insert new features.
Read-only property LengthField The geometry length field.
Read-only property ObjectClassID The unique ID for the object class.
Read-only property OIDFieldName The name of the field corresponding to the OID.
Read-only property RelationshipClasses The relationship classes in which this object class participates in for the specified role.
Method Search Returns an object cursor that can be used to fetch feature objects selected by the specified query.
Method Select Returns a selection That contains the object ids selected by the specified query.
Read-only property ShapeFieldName The name of the default sShape field.
Read-only property ShapeType The type of the default Shape for the features in this feature class.
Method Update Returns a cursor that can be used to update features selected by the specified query.

IFeatureClass.AreaField Property

The geometry area field.

Public ReadOnly Property AreaField As IField
public IField AreaField {get;}

Remarks

This read-only property returns the name of the field which records the area of each feature. Only feature classes that have a ShapeType of esriGeometryPolygon have an Area field.

A null pointer will be returned if:

  • the feature class does not have a shape type of esriGeometryPolygon
  • the underlying database does not maintain an area field
  • the feature class is a shapefile or CAD data

IFeatureClass.CreateFeature Method

Create a new feature, with a system assigned object ID and null property values.

Public Function CreateFeature ( _
) As IFeature
public IFeature CreateFeature (
);

Remarks

CreateFeaturewill create a new feature for the feature class. The new feature is by default assigned a unique object ID (OID). All other fields are initialized to null values if they can be made null and to built-in default values appropriate to the type of the field if they cannot be made null. Use the IFeature::Store method to actually store this new feature in the database. When working with a versioned feature class, CreateFeatureshould only be called within an edit session. You can start an edit session by calling IWorkspaceEdit::StartEditing. All edits to features that participate in a Topology or Geometric Network must be performed within an edit session and bracketed within an edit operation.

After calling CreateFeature, the default subtype value is not automatically set nor are default values initialized. For features without a subtype that have defined default values, calling IRowSubtypes::InitDefaultValues will initialize the default values. Use IRowSubtypes::SubtypeCode to set the subtype value for features with subtypes before calling IRowSubtypes::InitDefaultValues to initialize the default values for the particular subtype.

Calling the CreateFeaturemethod on a feature class (via the IFeatureClassinterface on the feature class) has the same effect as calling the CreateRowmethod on the FeatureClass (via the ITableinterface on the feature class) except that the IFeatureClassmethods return IFeatureinterfaces on the returned row object.

If multiple features with common attributes are being sequentially created, the CreateFeatureBuffermethod, IFeatureCursor.InsertFeature method and IFeatureBuffer interface should be used for better performance.

The basic process to create a new feature is:

1) Create the feature2) Create the geometry for the feature3) Store the geometry in the feature4) Store the feature

IFeatureClass.CreateFeatureBuffer Method

Create a feature buffer that can be used with an insert cursor.

Public Function CreateFeatureBuffer ( _
) As IFeatureBuffer
public IFeatureBuffer CreateFeatureBuffer (
);

Remarks

The CreateFeatureBuffermethod creates a feature buffer and returns the IFeatureBuffer interface. This can be used to create new features in the feature class with an insert cursor. Like creating a feature with IFeatureClass::CreateFeature, the field values for the new feature must be initialized to some value before it can be stored in the database. All edits to features that participate in a Topology or Geometric Network must be performed within an edit session and bracketed within an edit operation.

Calling the CreateFeatureBuffermethod in IFeatureClasshas the same effect as calling the CreateRowBufferinterface in ITableexcept that the IFeatureClassmethods return an IFeatureBufferinterface on the created row buffer.

IFeatureClass.FeatureClassID Property

The unique ID for the Feature Class.

Public ReadOnly Property FeatureClassID As Integer
public int FeatureClassID {get;}

Remarks

This read-only property will return the unique identifier for this feature class. All feature classes inside Geodatabases have a unique ID. Coverage and Shapefile feature classes do not, so IFeatureClass::FeatureClassID will always return -1 for Coverage and Shapefile feature classes. Since IFeatureClass inherits from IObjectClass, you can also get the feature class ID from IObjectClass:: ObjectClassID.

IFeatureClass.FeatureCount Method

The number of features selected by the specified query.

Public Function FeatureCount ( _
    ByVal QueryFilter As IQueryFilter _
) As Integer
public int FeatureCount (
    IQueryFilter QueryFilter
);

Remarks

FeatureCountreturns the number of features that satisfy some attribute and/or spatial query as specified by an IQueryFilter object. If Nothing is supplied for the IQueryFilter, then FeatureCount returns the total number of features in the feature class.

IFeatureClass.FeatureDataset Property

The feature dataset that contains the feature class.

Public ReadOnly Property FeatureDataset As IFeatureDataset
public IFeatureDataset FeatureDataset {get;}

Remarks

This read-only property returns the IFeatureDataset interface on the feature dataset that this feature class is a memeber of. If the feature class is a stand alone feature class (it does not have a feature dataset), then this function will return a null pointer. A coverage feature class will return the IFeatureDataset interface to the coverage itself. Shapefiles will always return a null pointer.

IFeatureClass.FeatureType Property

The type of features in this feature class.

Public ReadOnly Property FeatureType As esriFeatureType
public esriFeatureType FeatureType {get;}

Remarks

This read-only property returns the feature type for the feature class as an esriFeatureType value. This property can be used to determine if a feature class is of a particular type, in order for the feature class to added to a network or topology, or possibly to skip over the feature class in an enumerator.

IFeatureClass.GetFeature Method

Get the feature with the specified object ID.

Public Function GetFeature ( _
    ByVal ID As Integer _
) As IFeature
public IFeature GetFeature (
    int ID
);

Errors Returned

An error with the code FDO_E_FEATURE_NOT_FOUND will be raised if an invalid Object ID is specified.

Remarks

GetFeaturewill return a feature from the feature class with the parameter-specified Object ID (OID). This method is typically used to find a particular feature with a known Object ID. A cursor should be used to iterate through all features in a feature class.

Calling the GetFeaturemethod on a feature class (via the IFeatureClassinterface on the feature class) has the same effect as calling the GetRowmethod on the feature class**(via the ITableinterface) except that the return value is an IFeaturereference, rather than IRow**.

IFeatureClass.GetFeatures Method

Get a cursor of Rows given a set of object ids.

Public Function GetFeatures ( _
    ByVal fids As Object, _
    ByVal Recycling As Boolean _
) As IFeatureCursor
public IFeatureCursor GetFeatures (
    object fids,
    bool Recycling
);

Remarks

GetFeatureswill return an IFeatureCursor which contains the features from the feature class with the parameter-specified Object IDs (OID). This method can be used to loop through a particular set of features with known Object IDs.

Calling the GetFeaturesmethod from the IFeatureClassinterface**has the same effect as calling the GetRowsmethod from the ITableinterface**except that the return value is an IFeatureCursorreference, rather than an ICursor reference.

The _fids_parameter should be provided with an integer array. If the array contains an invalid Object ID, no error will occur, and no feature will be retrieved for the value.

This method should not be called from .NET or Java applications. Instead, call IGeoDatabaseBridge.GetFeatures.

IFeatureClass.Insert Method

Returns a cursor that can be used to insert new features.

Public Function Insert ( _
    ByVal useBuffering As Boolean _
) As IFeatureCursor
public IFeatureCursor Insert (
    bool useBuffering
);

Remarks

Insert creates an insert cursor on the feature class which can be used to insert new features into it.

Insert cursors can be used on instances of feature subclasses (such as network features) with guaranteed polymorphic behavior. Insert cursors can be used either inside or outside of an edit session. If used inside an edit session, the changes are not committed to the base table until the edit session is saved. Network feature classes, Topology feature classes, feature classes that participate in composite relationships or other relationships with messaging may only be updated within an edit session. If you attempt to use an insert cursor on one of these classes outside of an edit session, it will fail. In addition, inserts of features that participate in a Topology or Geometric Network must be bracketed within an edit operation.

If the insert cursor is created outside of an edit operation and new features are inserted within an edit operation, the changes are commited to the base tables. The additions to the base table cannot be undone. For this reason, insert cursors should typically be scoped to edit operations.

When using an insert cursor with simple features, IFeature.Store will not be called when a feature is inserted. If a class extension, editor extension or other custom implementation relies on the messages propagated from the Store method, this could cause a problem. The IObjectClassInfo interface can be implemented by a class extension to force a Store call when an insert cursor is used. Alternately, requiring Store calls can be specified across a workspace by setting the IWorkspaceEditControl.SetStoreEventsRequired property to true.

If the insert cursor is used to insert complex features (such as network features), the cursor will revert to using IFeature.Store.

When using cursors within an edit session, they should always be scoped to edit operations. In other words, a cursor should be created after an edit operation has begun and should not be used once that edit operation has been stopped or aborted.

IFeatureClass.LengthField Property

The geometry length field.

Public ReadOnly Property LengthField As IField
public IField LengthField {get;}

Remarks

This read-only property returns the name of the field which records the length of each feature. Only feature classes that have a ShapeType of esriGeometryPolygon or esriGeometryPolyLine have a Length field. For Line features, this field records the length of the polyline. For polygon features, this field records the perimeter of the polygon.

A null pointer will be returned if:

  • the feature class does not have a shape type of esriGeometryPolygon or esriGeometryPolyLine
  • the underlying database does not maintain an area field
  • the feature class is a shapefile or CAD data

IFeatureClass.Search Method

Returns an object cursor that can be used to fetch feature objects selected by the specified query.

Public Function Search ( _
    ByVal filter As IQueryFilter, _
    ByVal Recycling As Boolean _
) As IFeatureCursor
public IFeatureCursor Search (
    IQueryFilter filter,
    bool Recycling
);

Remarks

Searchwill return an IFeatureCursor with all of the features that satisfy the attribute and/or spatial constraints as specified by an IQueryFilter reference. If a null value is passed to the filter parameter, the feature cursor will return all of the features from the feature class.

The _recycling_parameter controls row object allocation behavior. Recycling cursors rehydrate a single feature object on each fetch and can be used to optimize read-only access, for example, when drawing. It is illegal to maintain a reference on a feature object returned by a recycling cursor across multiple calls to NextFeatureon the cursor. Features returned by a recycling cursor should not be modified. Non-recycling cursors return a separate feature object on each fetch. The features returned by a non-recycling cursor may be modified and stored with polymorphic behavior.

The Geodatabase guarantees "unique instance semantics" on non-recycling feature objects fetched during an edit session. In other words, if the feature retrieved by a search cursor has already been instantiated and is being referenced by the calling application, then a reference to the existing feature object is returned.

Non-recycling feature cursors returned from the Search method *MUST* be used when copying features from the cursor into an insert cursor of another class. This is because a recycling cursor reuses the same geometry and under some circumstances all of the features inserted into the insert cursor may have the same geometry. Using a non-recycling cursor ensures that each geometry is unique.

Existing rows can be edited with either a search cursor or an update cursor. When using a search cursor, NextRow is called, returning a reference to a row. The row is edited, and IRow.Store is called. When using an update cursor, NextRow is called, the row is edited, and ICursor.UpdateRow is called with the row as a parameter. It is important to remember, when using an update cursor, do _not_call the Store method.

In the same way, rows can be deleted using a search cursor or an update cursor, with IRow.Delete used instead of IRow.Store, and ICursor.DeleteRow used instead of ICursor.UpdateRow.

The recommended approach depends on whether or not the edits are being made in an edit session, if the cursor is being used by ArcMap or by an Engine application, and if the features being edited are simple or complex. The table below shows which approach to use in different situations:

ArcMap Engine - Simple Engine - Complex
Inside edit sessions Search Cursor Search Cursor Search Cursor
Outside edit sessions Search Cursor Update Cursor Search Cursor

A search cursor is always recommended in ArcMap, because the query may be satisfied by the contents of the map cache, making a DBMS query unnecessary.

When working with simple features and edit sessions in an Engine application, it's recommended that a search cursor be used to take advantage of batched updates in edit operations. With complex features, on the other hand, update calls are overridden by the features' custom behavior, meaning that the feature's store method will be called even if an update cursor is used.

When using cursors within an edit session, they should always be scoped to edit operations. In other words, a cursor should be created after an edit operation has begun and should not be used once that edit operation has been stopped or aborted.

IFeatureClass.Select Method

Returns a selection That contains the object ids selected by the specified query.

Public Function Select ( _
    ByVal QueryFilter As IQueryFilter, _
    ByVal selType As esriSelectionType, _
    ByVal selOption As esriSelectionOption, _
    ByVal selectionContainer As IWorkspace _
) As ISelectionSet
public ISelectionSet Select (
    IQueryFilter QueryFilter,
    esriSelectionType selType,
    esriSelectionOption selOption,
    IWorkspace selectionContainer
);

Remarks

Selectwill return an ISelectionSet with all of the features that satisfy some attribute and/or spatial query as specified by an IQueryFilter object. If Nothing is given as the IQueryFilter, then the selection will have all of the features from the feature class.

Calling the Selectmethod in IFeatureClasshas the same effect as calling the corresponding method in ITable.

The _selType_parameter determines the type of selection set that will be created: an ID set, a snapshot, or a hybrid. See the ISelectionSetinterface for a comparison of the three types.

When calling Select the selectionContainer parameter is no longer required. A null value should be passed as this parameter.

IFeatureClass.ShapeFieldName Property

The name of the default sShape field.

Public ReadOnly Property ShapeFieldName As String
public string ShapeFieldName {get;}

Remarks

This read-only property returns the name of the geometry field for the feature class.

IFeatureClass.ShapeType Property

The type of the default Shape for the features in this feature class.

Public ReadOnly Property ShapeType As esriGeometryType
public esriGeometryType ShapeType {get;}

Description

ShapeTypereturns the basic type of geometry of a shape. For the purposes of using the ShapeType property in deciding how to render/symbolize a layer, only esriGeometryPolyline, esriGeometryPolygon, esriGeometryPoint, esriGeometryMulitpoint,**andesriGeometryMultipatch need to be checked. All the other types will report as being one of these five types. The reason is that esriGeometryBezier3Curveor esriGeometryPath**, etc. can be segments or parts of another shape.

Remarks

This read-only property returns the shape type for the feature class. This shape type can be one of the following esriGeometryType.

IFeatureClass.Update Method

Returns a cursor that can be used to update features selected by the specified query.

Public Function Update ( _
    ByVal filter As IQueryFilter, _
    ByVal Recycling As Boolean _
) As IFeatureCursor
public IFeatureCursor Update (
    IQueryFilter filter,
    bool Recycling
);

Remarks

Updateopens an update cursor on the features specified by an attribute and/or spatial query as specified by the _filter_parameter. If a number of features selected by a particular query are to be updated and each feature is to be updated to a separate value then the update cursor is faster than doing an individual feature level update for each feature. The update is performed on the current 'cursor position'.

Update cursors can be used on instances of Feature subclasses (such as network features), with guaranteed polymorphic behavior. Update cursors can be used either inside or outside of an edit session. If used inside an edit session, the changes are not committed to the base table until the edit session is saved. Network feature classes, Topology feature classes, feature classes that participate in composite relationships or other relationships with messaging may only be updated within an edit session. If you attempt to use an update cursor on one of these classes outside of an edit session, it will fail. In addition, edits to features that participate in a Topology or Geometric Network must be bracketed within an edit operation.

When using cursors within an edit session, they should always be scoped to edit operations. In other words, a cursor should be created after an edit operation has begun and should not be used once that edit operation has been stopped or aborted.

Inherited Interfaces

Interfaces Description
IObjectClass Provides access to members that return information about an object class.
IClass Provides access to members that return information about and manage the class.

Classes that implement IFeatureClass

Classes Description
FeatureClass Esri Feature Class object.
RasterCatalog A collection of raster datasets in a Geodatabase table.
RelQueryTable An object that joins two datasets based on common data values.
XYEventSource XY event source object.

Remarks

Feature classes can be created using the IFeatureWorkspace.CreateFeatureClass and IFeatureDataset.CreateFeatureClass methods.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.