Connecting a broken line segment

Discussion created by emilharold on Apr 2, 2014
I'm working with a line feature representing a pipeline. There are breaks in the line with no feature. I would like to fill in those breaks with lines. Currently I'm basically drawing lines with end points and deleting anything over a certain length, but it's not perfect. Sometimes the gaps are larger, for example.

Is there a tool that does this for me by chance? It would essentially select feature end points that are closest to one another and create line features from them. It would also ignore the first start and last end point.


#create end points from merged pipeline
arcpy.FeatureVerticesToPoints_management (thePipeLine, "PipeLineEndPoints", "BOTH_ENDS")
#create lines from end points
arcpy.PointsToLine_management ("PipeLineEndPoints", "EndPointLns", Close_Line = "CLOSE")
#split line at verticies
arcpy.SplitLine_management ("EndPointLns", str(Geodatabase)+"\\SplitEndLines")
#Create layer from end point lines
arcpy.MakeFeatureLayer_management (str(Geodatabase)+"\\SplitEndLines","EndPointLineslyr")
#Select long lines >20 meters
arcpy.SelectLayerByAttribute_management ("EndPointLineslyr", "NEW_SELECTION", '"Shape_Length" >20')
#Delete long lines >20 meters
arcpy.DeleteFeatures_management ("EndPointLineslyr")
#Merge pipeline with gap lines
arcpy.Merge_management ([thePipeLine,str(Geodatabase)+"\\SplitEndLines"], "ConnectedPipe")