ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / MultipartToSinglePart Method
The geometry to make into single component geometries
Example

In This Topic
    MultipartToSinglePart Method (IGeometryEngine)
    In This Topic
    Separates the components of a geometry into single component geometries.
    Syntax
    IReadOnlyList<Geometry> MultipartToSinglePart( 
       Geometry geometry
    )
    Function MultipartToSinglePart( _
       ByVal geometry As Geometry _
    ) As IReadOnlyList(Of Geometry)

    Parameters

    geometry
    The geometry to make into single component geometries

    Return Value

    Read-only list of geometries
    Exceptions
    ExceptionDescription
    Not implemented for Multipatch.
    Spatial reference of geometryis an image coordinate system.
    Remarks
    A single part geometry will not be affected (i.e. it will just get passed along) with the exception of a multipoint which will become points. The number of output geometries may not equal the number of parts in the input geometry. For example, if a polygon has a hole, then the outer ring and inner ring are returned as one geometry.
    Example
    Separate components of a geometry into single component geometries
    List<Coordinate2D> coords2D = new List<Coordinate2D>()
      {
        new Coordinate2D(0, 0),
        new Coordinate2D(1, 4),
        new Coordinate2D(2, 7),
        new Coordinate2D(-10, 3)
      };
    
    Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords2D, SpatialReferences.WGS84);
    
    IReadOnlyList<Geometry> result = GeometryEngine.Instance.MultipartToSinglePart(multipoint);
    // result.Count = 4, 
    
    
    // 'explode' a multipart polygon
    result = GeometryEngine.Instance.MultipartToSinglePart(multipartPolygon);
    
    
    // create a bag of geometries
    Polygon polygon = PolygonBuilderEx.CreatePolygon(coords2D, SpatialReferences.WGS84);
    //At 2.x - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(new List<Geometry>() { multipoint, polygon });
    var bag = GeometryBagBuilderEx.CreateGeometryBag(new List<Geometry>() { multipoint, polygon });
    // bag.PartCount = =2
    
    result = GeometryEngine.Instance.MultipartToSinglePart(bag);
    // result.Count == 2
    // result[0] is MultiPoint
    // result[1] is Polygon
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also