Select to view content in your preferred language

Order intersections of a polyline by distance

528
1
10-20-2020 06:30 PM
KevinTelles
New Contributor II

Given a polyline L and a set S of polylines that intersect L. I need to order S based on the distance of each element to the start o L.


For example:

I tried using geometryEngine to find the intersections and calculated the distance of L to each intersection. However this won't work in some specific cases when L forms a curve. What I really needed is to calculate the distance along L to the intersection, but I couldn't find anything in the javascript API that did this.

Is there a better way to accomplish this?

0 Kudos
1 Reply
UriGilad_EsriAu
Esri Contributor

Hi Kevin,

You can do this task by using toolboxes in a desktop environment, then wrap the process in an arcpy script. If you want it in a web environment you'll have to create a tool from your arcpy script and publish as a GP Tool.

Workflow:

1. Run the intersection tool - make sure to select Points as output type. This will create points at the intersections.

2. Select L and copy to a temp layer. Select S1's intersection point.

3. Use the 'Split Line at Point' tool to split L (in the temp layer) at S1.

4. Now L will be split in two. By using a search cursor you can get the shape length from the attribute table (if your data is in degrees create a new field and calculate geometry in projected units). Get the distance measure from the first part of the line - that will be the distance from start to intersection.

5. Repeat steps 2-4 with the different S intersection points.

Another workflow can be achieved with linear referencing:

1. Make your L a route with m-values.

2. Create the points as per step 1 in first workflow.

3. By using the 'Locate Features Along Route' tool get the m-value at the points' locations.

Hope this helps,

Uri


If this answer solved your question or if you found it helpful please mark it accordingly to help others who have the same question.