Parameters
- geometry1
- The first geometry to union with.
- geometry2
- The second geometry to union with.
Return Value
A geometry representing the union of the input geometries.
Exception | Description |
---|---|
System.ArgumentNullException | Either geometry1 or geometry2 or both are null or empty. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.InvalidOperationException | Incompatible spatial references between the input geometries. |
InvalidParameterException | Input geometries do not have the same dimension. |
GeometryObjectException | The operation cannot be performed on a non-simple geometry. |
System.NotImplementedException | Spatial reference of geometry1or geometry2is an image coordinate system. |
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0); MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5); Geometry geometry = GeometryEngine.Instance.Union(pt1, pt2); Multipoint multipoint = geometry as Multipoint; // multipoint has point count of 2
// union two polygons List<MapPoint> polyPts = new List<MapPoint>(); polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly1); Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8)); Polygon poly2 = PolygonBuilder.CreatePolygon(env); isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly2); Geometry g = GeometryEngine.Instance.Union(poly1, poly2); Polygon polyResult = g as Polygon;
Target Platforms: Windows 10, Windows 8.1