ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryBagBuilderEx Class / CreateGeometryBag Method / CreateGeometryBag(IEnumerable<Geometry>,SpatialReference) Method
The list of geometries to create the GeometryBag.
(Optional) The SpatialReference. The default value is null. The spatial reference of each geometry is ignored.
Example

In This Topic
    CreateGeometryBag(IEnumerable<Geometry>,SpatialReference) Method
    In This Topic
    Convenience method to create a new instance of the GeometryBag class.
    Syntax
    Public Overloads Shared Function CreateGeometryBag( _
       ByVal geometries As IEnumerable(Of Geometry), _
       Optional ByVal spatialReference As SpatialReference _
    ) As GeometryBag

    Parameters

    geometries
    The list of geometries to create the GeometryBag.
    spatialReference
    (Optional) The SpatialReference. The default value is null. The spatial reference of each geometry is ignored.

    Return Value

    Exceptions
    ExceptionDescription
    geometries is null.
    A geometry in geometries is null. You cannot insert a null geometry into a GeometryBag.
    A geometry in geometries is GeometryBag. You cannot insert a GeometryBag into another GeometryBag.
    Example
    Construct GeometryBag - from an enumeration of geometries
    // Use a builder convenience method or use a builder constructor.
    
    MapPoint point = MapPointBuilderEx.CreateMapPoint(10, 20);
    List<Coordinate2D> coords = new List<Coordinate2D>() { new Coordinate2D(50, 60), new Coordinate2D(-120, -70), new Coordinate2D(40, 60) };
    Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords, SpatialReferences.WebMercator);
    Polyline polyline = PolylineBuilderEx.CreatePolyline(coords);
    
    string json = "{\"rings\":[[[0,0],[0,1],[1,1],[1,0],[0,0]],[[3,0],[3,1],[4,1],[4,0],[3,0]]]}";
    Polygon polygon = PolygonBuilderEx.FromJson(json);
    
    var geometries = new List<Geometry>() { point, multipoint, polyline, polygon };
    
    // Builder convenience methods don't need to run on the MCT.
    //At 2.x - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(geometries, SpatialReferences.WGS84);
    var bag = GeometryBagBuilderEx.CreateGeometryBag(geometries, SpatialReferences.WGS84);
    
    //At 2.x - using (var builder = new GeometryBagBuilder(geometries, SpatialReferences.WGS84)) 
    var builder = new GeometryBagBuilderEx(geometries, SpatialReferences.WGS84);
    // do something with the builder
    bag = builder.ToGeometry();
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also