ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryBagBuilderEx Class / RemoveGeometry Method
0 based index. Specify 0 to remove the first geometry. Specify (Count - 1) or -1 to remove the last geometry.
Example

In This Topic
    RemoveGeometry Method
    In This Topic
    Remove the geometry specified by the given index.
    Syntax
    Public Sub RemoveGeometry( _
       ByVal index As Integer _
    ) 
    public void RemoveGeometry( 
       int index
    )

    Parameters

    index
    0 based index. Specify 0 to remove the first geometry. Specify (Count - 1) or -1 to remove the last geometry.
    Exceptions
    ExceptionDescription
    Index must be less than the number of geometries in the builder or equal to -1.
    Example
    Construct GeometryBag
    {
      MapPoint point = MapPointBuilderEx.CreateMapPoint(1, 2, SpatialReferences.WebMercator);
    
      List<Coordinate2D> coords2DToUse = new List<Coordinate2D>()
      {
        new Coordinate2D(0, 0),
        new Coordinate2D(0, 1),
        new Coordinate2D(1, 1),
        new Coordinate2D(1, 0)
      };
    
      Multipoint multipointNew = MultipointBuilderEx.CreateMultipoint(coords2DToUse, SpatialReferences.WGS84);
      Polyline polylineNew = PolylineBuilderEx.CreatePolyline(coords2DToUse, SpatialReferences.WebMercator);
    
      GeometryBagBuilderEx builder = new GeometryBagBuilderEx(SpatialReferences.WGS84);
    
      GeometryBag emptyBag = builder.ToGeometry();
      // emptyBag.IsEmpty = true
    
      builder.AddGeometry(point);
      // builder.GeometryCount = 1
    
      GeometryBag geometryBag = builder.ToGeometry();
      // geometryBag.PartCount = 1
      // geometryBag.PointCount = 1
      // geometryBag.IsEmpty = false
    
      IReadOnlyList<ArcGIS.Core.Geometry.Geometry> geometries = geometryBag.Geometries;
      // geometries.Count = 1
      // geometries[0] is MapPoint with a sr of WGS84
    
      bool isEqual = geometryBag.IsEqual(emptyBag);   // isEqual = false
    
      builder.InsertGeometry(0, multipoint);
      geometryBag = builder.ToGeometry();
      // geometryBag.PartCount = 2
    
      geometries = geometryBag.Geometries;
      // geometries.Count = 2
      // geometries[0] is Multipoint
      // geometries[1] is MapPoint
    
      builder.AddGeometry(polyline);
      builder.RemoveGeometry(1);
      geometryBag = builder.ToGeometry();
      // geometryBag.PartCount = 2
    
      geometries = geometryBag.Geometries;
      // geometries.Count = 2
      // geometries[0] is Multipoint
      // geometries[1] is Polyline          
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also