Let's consider these 2 feature classes below, both of them are simple single-part lines. I need to find a reliable way to get the first and last intersection points between them (the green and yellow ones). I tried applying the Intersect tool to obtain all the points where the features overlap. I got the following result: The problem is that the tool gave me a multipoint feature class, with one feature for each line segment of the yellow feature class that was intersected. Here is a screenshot of the table of contents: I tried to convert this multipoint feature class to a single-part one using the Multipart to Singlepart tool, but the resulting features are completely unordered and messy.
TL;DR: How to reliably find the first and last intersection points from two given lines that intersect each other multiple times along the way?
P.S.: We use ArcGIS. Although I think it's a more logic-related problem than a platform-specific one. I am aware that some RDBMS offer functions like ST_StartPoint for PostgresSQL, but I really would like to keep it a platform-agnostic, python-based solution.
P.P.S.: There are some curious edge cases that I've already stumbled upon that I think are important to point out. Here is one of them: If you only consider absolute distances between the points and the endpoint of the green feature, the black intersection point is closer than the blue one, leading to an incorrect result. The blue dot is what we are looking for.