IGeometryBag vs. IGeometryCollection


Summary
These two interfaces seem related in name but perform important yet different roles.

In this topic


About IGeometryBag vs. IGeometryCollection

IGeometryBag and IGeometryCollection are two interfaces that serve different purposes. The main functions of IGeometryBag are the spatial reference of the geometry or geometries that are referenced as elements of the GeometryBag.
IGeometryCollection functions involve the creation of new geometries from collections of simpler geometries. IGeometryCollection can insert and rearrange elements within the composite object as well as create the composite objects from constituent parts.
IGeometryBag
IGeometryBag gives the user access to methods that affect the spatial reference of a GeometryBag and the geometry references it contains. Setting the spatial reference of IGeometryBag before adding references to geometries to the GeometryBag is important. Without this step, the geometry's spatial reference is automatically set to whatever the GeometryBag's spatial reference is even if it is not defined.
Geometries added to the GeometryBag inherit the GeometryBag spatial reference. Make sure the geometries you plan to reference are already in the same coordinate system. However, if the resolution and spatial domain values differ, you can use the SnapToSpatialReference method to ensure that all the elements have the same resolution value and coordinate grid.
Resolution and coordinate grid values are important if you want to do any analysis on the data particularly using ITopologicalOperator or IRelationalOperator. With the Project method, you can change the spatial reference of the GeometryBag and all of its elements. If the input and output spatial references use different geographic coordinate systems, it is important to remember that the Project method will not work if the GeoTransformationOperationSet does not contain an appropriate GeoTransformation.
You cannot call the Project method on a GeometryBag that does not have its spatial reference property defined. Also, the Project and ProjectEx methods should not be applied to GeometryBag if it contains segments, as this is not supported and results in an error. These methods and properties are powerful and allow properties to be changed in all elements of the GeometryBag.
IGeometryCollection
IGeometryCollection is implemented by several collection objects including GeometryBag. IGeometryCollection allows the addition, removal, insertion, and manipulation of elements from these collection objects. Also, setting specific parts of a composite geometry is available with this interface.
Only the following two properties are accessible in read-only format from IGeometryCollection:
Several of the methods on IGeometryCollection that involve adding arrays of geometries must be performed using IGeometryBridge or IGeometryBridge2 when programming in Java or any of the .NET languages.
After changing the properties of the elements referenced in a collection object, it is important to call IGeometryCollection.GeometriesChanged so that it can delete any cached properties it may be maintaining, such as envelope, length, or area.






Development licensingDeployment licensing
Engine Developer KitEngine
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced