Intersection(Geometry,Geometry,GeometryDimensionType) Method
Constructs the set-theoretic intersection between two geometries.
Use different resultDimensionType values to generate results of different dimensions.
Parameters
- geometry1
- The first geometry.
- geometry2
- The second geometry.
- resultDimensionType
- Specifies the required dimension of the output. For example, if is a Polyline and is a Polyline and they cross each other at two points, then the intersection is a Multipoint. In this case, if you want the returned geometry to be the Multipoint where the input geometries intersect, use GeometryDimensionType.EsriGeometry0Dimension. Note that if the geometries intersect at one point and GeometryDimensionType.EsriGeometry0Dimension is used, the returned geometry will be a Multipoint with one point. In the above example, if GeometryDimensionType.EsriGeometry1Dimension is passed, an empty Polyline will be returned because the geometries intersect only at points. If, on the other hand, the two polylines overlap, then a non-empty Polyline will be returned. If is GeometryDimensionType.EsriGeometryUnknownDimension, then the lowest dimension of the input geometries will be used.
Return Value
A geometry that represents the intersection of the two input geometries.
Intersection between two Polylines
// determine intersection between two polylines
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0));
pts.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0));
Polyline line1 = PolylineBuilderEx.CreatePolyline(pts);
List<MapPoint> pts2 = new List<MapPoint>();
pts2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0));
pts2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0));
pts2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0));
Polyline line2 = PolylineBuilderEx.CreatePolyline(pts2);
bool intersects = GeometryEngine.Instance.Intersects(line1, line2); // intersects = true
Geometry g = GeometryEngine.Instance.Intersection(line1, line2, GeometryDimensionType.EsriGeometry0Dimension);
Multipoint resultMultipoint = g as Multipoint;
// result is a multiPoint that intersects at (2,2) and (4,2)
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.