I'm trying to put a list of point features (selected points) into a new FeatureClass. but when I add them to my FeatureClass I get the "Geometry cannot have Z values." exception on the line "buff.Shape = point;" . can any one help?
List<IFeature> features = GetSelectedFeatures(axMapControl1.get_Layer(0) as IFeatureLayer);
IPointArray pa = new PointArrayClass();
List<IPoint> p = new List<IPoint>();
for (int i = 0; i < features.Count; i++)
{
p.Add(features[i].ShapeCopy as IPoint);
pa.Add(p[i]);
}
IPoint point = new PointClass();
point = pa.get_Element(0);
point.SpatialReference = p[0].SpatialReference;
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
IWorkspace workspace = workspaceFactory.OpenFromFile(@"C:\", 0);
IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;
IFeatureClass FC = CreateFeatureClass("FC", featureWorkspace, pa.get_Element(0).SpatialReference,esriGeometryType.esriGeometryPoint);
IFeatureCursor fCur = FC.Insert(false);
IFeatureBuffer buff = FC.CreateFeatureBuffer();
buff.Shape = point;
fCur.InsertFeature(buff);
fCur.Flush();
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(fCur);
IFeatureLayer fl = new ESRI.ArcGIS.Carto.FeatureLayer();
fl.FeatureClass = FC;
var layer = fl as ILayer;
axMapControl1.AddLayer(layer);
axMapControl1.Refresh();