Lines in question

I have two nonparallel lines and I need to find the average line between them. This is proving to be more difficult than expected.

Is there a fairly simple way to do this?

I thought I could use a series of points for each line, then find the mid point of each set of points then created a line using said points, however this didn't work has I had hoped. The lines are not the same length fyi. I do have an ArcGIS Advanced license.

  • 1
    What do you mean by 'average line between them' ? – ami Dec 2 '16 at 16:05
  • Kind of like a line of best fit. – Katie B. Dec 2 '16 at 16:42
  • 1
    Have you tried collapse lines output? – FelixIP Dec 2 '16 at 18:32
  • @FelixIP It doesn't provide the result I need. I think it doesn't work because the lines are not parallel. – Katie B. Dec 5 '16 at 18:42
  • Try Euclidian allocation. Define small cell size in environments. Convert result raster to polygon, and lines. – FelixIP Dec 5 '16 at 19:19

Neither of my suggestions works. I have my own script to handle this, but I am not prepared to share it. Let’s try to solve it with minimum scripting by using linear referencing:

## create anchor points at intersections
arcpy.Intersect_analysis("LINES", "D:/Scratch/mpoints.shp","ALL", output_type = "POINT")
# calculate their distance along the line
arcpy.AddField_management("anchors", "CHAINAGE", "DOUBLE")

Run this field calculator expression on field CHAINAGE

def Chainage(shp):
 mxd = arcpy.mapping.MapDocument("CURRENT")
 with arcpy.da.SearchCursor(lr, 'Shape@') as cursor:
  for row in cursor:  geom=row[0]
 L=geom.measureOnLine (shp.firstPoint)
 return int(L)
Chainage(!Shape! )

#sort anchor points accordingly
arcpy.Sort_management("anchors","D:/Scratch/sorted.shp", "CHAINAGE ASCENDING")

enter image description here

Create multiple rows table in Excel. I've made it 1240 rows long (1274-35+1) in order to place points on the line at about 1 m apart:

enter image description here

and bring this table to mxd

# Place ‘equally’ spaced points on BLUE line
arcpy.CalibrateRoutes_lr("LINES", "Name", "sorted", "Name", "CHAINAGE","D:/Scratch/routes.shp")
arcpy.MakeRouteEventLayer_lr("routes", "Name", "from_Excel", "LINE POINT m", "BLUE_POINTS", point_event_type="POINT")

Repopulate NAME fields in “sorted” and “from_Excel” and create points on RED line.

# create cross-lines
arcpy.Merge_management("RED_POINTS;BLUE_POINTS", "D:/Scratch/merged.shp")
arcpy.PointsToLine_management("merged", "D:/Scratch/grey_sections.shp", Line_Field="M")
# compute their mid points and draw the line
arcpy.FeatureVerticesToPoints_management(“grey_sections", “D:/Scratch/mid_points.shp", "MID")
arcpy.PointsToLine_management("mid_points", "..Green_Line.shp", Sort_Field="M")

enter image description here


  • to handle sharp turns one might convert red/blue lines to polygons and clip "grey" lines using these polygons. Use mid points of clipped version to construct final line
  • Append anchor points to mid points, to force line going through all intersections. ArcGIS refuses to create "grey" line out of 2 coincident points

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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