1
               IPointCollection pointcollection = new MultipointClass();              
                p.PutCoords(x.lon, x.lat);
                pointcollection.AddPoint(p);
                IGeometry geometry = pointcollection as IGeometry;
                 featureBuffer.Shape = geometry;//error here This geometry 
                                                   type is not supported

If I want to add lots of point features, what else can I do?

1
  • You cannot add a multipoint to a point shapefile. These are incomparable types. While is is possible to add a single-part multipoint to a multipoint shapefile, the storage is significantly larger, because it also needs to store an envelope and the number of parts.
    – Vince
    Commented Dec 19, 2018 at 5:23

1 Answer 1

2

I think you're having trouble because IPointCollection does't implement IGeometry or because you haven't set the spatial reference property, to add lots of points to a point collection as a multipoint, assuming your X and Y values are stored as an array or list:

object gMissing = System.Type.Missing;

IMultipoint pMulPoint =  new MultipointClass();
IPointCollection pointcollection = pMulPoint as IPointCollection;

for (index = 0;index < pointcount;index++)
{
  IPoint p = new PointClass(); // important!
  p.PutCoords(x[index],y[index]);
  pointcollection.AddPoint(p, ref missing, ref missing);
}
IGeometry Geom = (IGeometry)pMulPoint;
Geom.SpatialReference = yourSpatialReference; // important!

See an example at https://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/000100000mrv000000.htm not that I deal with multipoints much, usually I deal with point, polyline or polygon objects, but multipoints are a special case not needing to proceed via IGeometryCollection to an IGeometry.

However this assumes your feature class is of type Multipoint, if it's of type Point then you can't store a multipoint in the same way you can't put polygons or polylines or TINs or rasters into the feature class... they're the wrong sort of geometry to fit in the assigned space.

If you're creating point features in a point feature class then simply:

IPoint p = new PointClass();
p.PutCoords(x.lon, x.lat);
p.SpatialReference = yourSpatialReference; // important!
featureBuffer.Shape = p;
2
  • If I want to add point features,the most effective way is using IFeatureClass.CreateFeatureBuffer with an insert cursor? Like Cursor.InsertFeature(FeatureBuffer)?
    – getti
    Commented Dec 19, 2018 at 12:22
  • Yes, the performance of an insert cursor with an IFeatureBuffer is superior to that of IFeature.Store() as mentioned in the help resources.arcgis.com/en/help/arcobjects-net/componenthelp/… Commented Dec 20, 2018 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.