Select to view content in your preferred language

add features to existing shapefile

5221
4
08-17-2010 02:31 AM
YashikaSareen
Emerging Contributor
Hi everyone,
Today I am stuck up with a new problem.
I need to develop a tool in which i have to add the features to an existing shapefile and store them.I understand only c#.can any1 help me with the code.
0 Kudos
4 Replies
DanielTuracek
Emerging Contributor
0 Kudos
NirYoscovitz
Emerging Contributor
Hi,

You can use IFeatureClass.CreateFeature and IFeature.Store for a single feature
or insert cursor for a group of features.

See

http://resources.esri.com/help/9.3/ArcGISEngine/dotnet/e7b33417-0373-4f87-93db-074910907898.htm

Regards,
Nir
0 Kudos
YashikaSareen
Emerging Contributor
hi
i tried to use the above said methods but unable to get the desired result.
Can any1 provide me with the code to add the features to an existing shape file so that i can understand..
thanks in advance.

Yashika Sareen:confused:
0 Kudos
AndrewMay
Emerging Contributor
Hi
The link from Nir's reply above seems to have a decent c# example.  What problem are you having getting this to do what you want?

public static void CreateFeature(IFeatureClass featureClass, IPolyline polyline)
{
  // Build the feature.
  IFeature feature = featureClass.CreateFeature();
  feature.Shape = polyline;

  // Apply the appropriate subtype to the feature.
  ISubtypes subtypes = (ISubtypes)featureClass;
  IRowSubtypes rowSubtypes = (IRowSubtypes)feature;
  if (subtypes.HasSubtype)
  {
    // In this example, the value of 3 represents the PVC subtype.
    rowSubtypes.SubtypeCode = 3;
  }

  // Initialize any default values the feature has.
  rowSubtypes.InitDefaultValues();

  // Update the value on a string field that indicates who installed the feature.
  int contractorFieldIndex = featureClass.FindField("CONTRACTOR");
  feature.set_Value(contractorFieldIndex, "K Johnston");

  // Commit the new feature to the geodatabase.
  feature.Store();
}
0 Kudos