merge polyline paths

Somebody on the team was having trouble tracing streams due to breaks in the streams introduced when converting raster to feature.

So here is slick little solution which takes n paths in a line features and makes a 1 path (aka 1 part) out of it.
None of the vertices are moved. Where there were two paths separated by a gap you will have one path with no gap.

To work property the paths have to be pointed in the same direction and not be converging. To deal with that would require quite a bit more logic.

As is script modified data in place, so back up your data before using.


One thought on “merge polyline paths

  1. I was constrained by having to use Arc 10.0 for a similar task, but I believe this script will do the same thing in version 10.0:

    def connect_parts(fc):
    desc = arcpy.Describe(fc)
    shapefieldname = desc.ShapeFieldName
    rows = arcpy.UpdateCursor(fc)
    for row in rows:
    feat = row.getValue(shapefieldname)
    if feat.isMultipart == True:
    pntArray = arcpy.Array()
    for part in feat:
    for pnt in part:
    Shape = arcpy.Polyline(pntArray)
    del pntArray
    row.Shape = Shape
    del Shape
    del rows

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s