﻿ Crosses Method (GeometryEngine)—ArcGIS Pro
ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / Crosses Method
The base geometry.
The comparison geometry.
Example

In This Topic
Crosses Method (GeometryEngine)
In This Topic
Returns true if geometry1 crosses geometry2.
Syntax
```public bool Crosses(
Geometry geometry1,
Geometry geometry2
)```
```Public Function Crosses( _
ByVal geometry1 As Geometry, _
ByVal geometry2 As Geometry _
) As Boolean```

#### Parameters

geometry1
The base geometry.
geometry2
The comparison geometry.

#### Return Value

True if the geometry1 crosses geometry2.
Exceptions
ExceptionDescription
Either geometry1 or geometry2 or both are null.
The method is not implemented for GeometryBag.
Incompatible spatial references between the input geometries.
Remarks
A polyline crosses another polyline if they share only points in common, at least one of which is not an endpoint. A polyline crosses a polygon if at least one path of the polyline is partly inside the polygon and partly outside.

Example
Determine if two geometries cross
```//
// pt on pt
//

MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.0);

bool crosses = GeometryEngine.Instance.Crosses(pt, pt2);         // crosses = false
crosses = GeometryEngine.Instance.Crosses(pt, pt);               // crosses = false

//
// pt and line
//

List<MapPoint> list = new List<MapPoint>();

Polyline line1 = PolylineBuilderEx.CreatePolyline(list);
crosses = GeometryEngine.Instance.Crosses(line1, pt2);           // crosses = false
crosses = GeometryEngine.Instance.Crosses(pt2, line1);           // crosses = false
// end pt of line
crosses = GeometryEngine.Instance.Crosses(line1, pt);            // crosses = false

//
// pt and polygon
//
List<MapPoint> polyPts = new List<MapPoint>();

Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts);
crosses = GeometryEngine.Instance.Crosses(poly1, pt);              // crosses = false
crosses = GeometryEngine.Instance.Crosses(pt, poly1);              // crosses = false

//
// line and line
//
List<MapPoint> list2 = new List<MapPoint>();

Polyline line2 = PolylineBuilderEx.CreatePolyline(list2);
crosses = GeometryEngine.Instance.Crosses(line1, line2);           // crosses = true

//
// line and polygon
//
crosses = GeometryEngine.Instance.Crosses(poly1, line1);           // crosses = true

//
// polygon and polygon
//
Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4));
Polygon poly2 = PolygonBuilderEx.CreatePolygon(env);
crosses = GeometryEngine.Instance.Crosses(poly1, poly2);           // crosses = false
```
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.