ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / Touches Method
The base geometry.
The comparison geometry.
Example

In This Topic
    Touches Method (GeometryEngine)
    In This Topic
    Returns true if geometry1 touches geometry2.
    Syntax
    Public Function Touches( _
       ByVal geometry1 As Geometry, _
       ByVal geometry2 As Geometry _
    ) As Boolean

    Parameters

    geometry1
    The base geometry.
    geometry2
    The comparison geometry.

    Return Value

    True if geometry1 touches 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
    Two geometries touch if the intersection of the interiors is empty, but their intersection is not empty. In other words, their intersection contains only boundary points.

    GeometryEngine Touches

    Example
    Polygon touches another Polygon
    // two disjoint polygons
    Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(4.0, 4.0), MapPointBuilderEx.CreateMapPoint(8, 8));
    Polygon poly1 = PolygonBuilderEx.CreatePolygon(env);
    
    Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(5, 5));
    Polygon poly2 = PolygonBuilderEx.CreatePolygon(env2);
    
    bool touches = GeometryEngine.Instance.Touches(poly1, poly2);    // touches = false
    
    // another polygon that touches the first
    Envelope env3 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4));
    Polygon poly3 = PolygonBuilderEx.CreatePolygon(env3);
    
    touches = GeometryEngine.Instance.Touches(poly1, poly3);         // touches = true
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also