I have a polyline shapefile depicting a real road network. In many parts it has two 100 % overlapping segments in opposite directions, representing the two driving directions (In picture: red segments). The perpendicular lines are the start and end points of the segments.

How could I easily select the red segments that share the direction of the black line? (In picture: those red segments that are directed towards North East). So far I can only automatically find the overlapping (with black line) red segments of both directions.

I have a route as a 1-part line (In picture: black line). This is derived from the same road network so the geometry is actually overlapping with the red segments.

I was thinking about this kind of a process, after finding the red segments that overlap with the black polyline:
1) For each red segment
          calculate the azimuth (angular direction)
2) Determine the end points of the red segments
3) Split the black line at both end points of the red segments
4) For each split black segment
          calculate the azimuth
          determine the overlapping 2 red segments
          copy the red segment that has the same azimuth (or withing a marginal)

BUT, is there an easier way or a tool? I would like to do this using ArcMap 10.2 Standard or ArcPy.

The route might be twisty so I can't use a global azimuth. I need to filter a complete road network (red lines) with n routes (black lines).

Picture: Filter overlapping segments by direction

3 Answers 3


Okay, this workflow fixed the problem.

If any red segment is overlapping with another red segment:
1) Calculate start and end points of each red lines. Remove spatial duplicates.
2) Split the black line by points.
3) Calculate the azimuth of each split black line.
4) Create a buffer around each split black line & find the red segments completely within the buffer.
5) Choose the red segment with the right direction (azimuth).

This maybe is not that beautiful a solution, but works nonetheless.

I ran into the problem of not having Advanced (Info) license, thus not having the 'Split Line at Point' tool. However, this script seems to do the trick: https://www.queryxchange.com/q/23_154708/standalone-python-script-to-split-a-polyline-with-a-point-layer/


(Solution 2) Actually the real goal, after all, was to identify the segments between a point pair (times N) on a road network & perform some calculations on the attributes. I could solve the problem with Network Analyst as well, because the routes were generated with Network Analyst. This was possible using

Copy Traversed Source Features functionality:

Edges feature class that is generated has the SourceOID field, which is a reference to the original road network .shp FID.

Anyway, implementing your own solutions is always good.

  1. Calculate points at the line ends
  2. Remove spatial duplicates, assign unique name to points.
  3. Assign from and to nodes to lines
  4. Run this field calculator on new integer type field in roads table

def FirstOrNext(f,t):
 global aList
 if key in aList:
  return 2   
 return 1

FirstOrNext( !fromn!, !ton!)

Value 2 in you field marks 'duplicate' line

  • Than you very much for your response Felix. It took me some time to test this method. Yes this finds the duplicates, but not the red segments that go in the right direction (the same as the black line). Assigning from and to nodes to the start and end points of the black line could maybe work, for deriving the "right" direction and choosing the corresponding red segments (having either increasing or decreasing from to node ID order).
    – Belford
    Sep 24, 2015 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.