Select to view content in your preferred language

Polylines touch and cross behaviour

2078
14
11-20-2024 08:28 PM
EugeneSosnin_GSI
Emerging Contributor

Given two arcpy.Polyline geometries.

If they only touch each other:

poly1.touches(poly2) == True

if poly2 touches and at the same time crosses poly1:

poly1.touches(poly2) == False

poly1.crosses(poly2) == True

Therefore, I offer to change the logic. If they touch - it's True, whatever other relations they have.

14 Comments
AnnetteLocke

By definition, if two polylines cross, then they don't touch and vice versa. Here's how it works. The interior of a polyline is the set of points in the polyline that are not start or end points of a path. If the intersection of the interiors is empty, but the intersection of the polylines is not empty (they intersect only at start or end points of a path), then the polylines touch. Two polylines cross if they meet at points only, and at least one of the shared points is internal to both polylines.
See https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Geometry#predefined-relational-operations

For your case, you can use the Relation operator. See https://developers.arcgis.com/python/latest/api-reference/arcgis.geometry.html#relation

EugeneSosnin_GSI

@AnnetteLocke , thank you for the answer. I got your point, and I appreciate the tip for using Relation operator in ArcGIS API for Python. Thought, could we do something with Arcpy? Like add a Relation method to Arcpy, or a parameter to the touch method to find true relation, even if interiors intersect? Please. 

AnnetteLocke

Eugene, thank you for the suggestion. The Relation method will be added to ArcPy in a future release.

HannesZiegler
Status changed to: Under Consideration

You've got our attention!  We think this is a good suggestion and have entered it in our backlog.  We encourage the community to continue voting and sharing feedback which will help teams gauge user demand.