I have a polyline which is divided into multiparts and these parts are not well ordered so that the vertex's ID are not following the polyline's plotting.

This polyline is a representing a bus line and I need to have the plotting following the driving way of the bus. I would like to know how to merge the multiparts of this polyline?

I have already tried to Split and Unsplit, as well as Multipart to Single Part, Union, Merge, etc. but no one is giving me the result I want.

  • @bmoussea, did you use the Dissolve tool? – artwork21 Jun 15 '11 at 15:34
  • @artwork21 Yes I did, but it doesn't change anything: the polyline is still divided in multiparts... – bmoussea Jun 15 '11 at 15:47
  • Check Geometry verify that the multi-part is ordered correctly first help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… then dissolve a artwork21 mentions – Mapperz Jun 15 '11 at 15:49
  • I checked the geometry and there are no problem reported. The multiparts do not appears in the checkgeometry because they are already parts of the polyline. – bmoussea Jun 15 '11 at 16:17
  • The multiparts of my polyline appear when editing the layer where my polyline is, and then right clic on it -> Edit Vertices and look in the Sketch Properties. Here are the differents parts (multiparts) of my polyline I would like to merge. – bmoussea Jun 15 '11 at 16:31

I see from your tags that you are running ArcGIS 10. I've used the following method for a similar task:

1) Use Multipart to Single Part

2) Use Unsplit

In order for this to work (i.e. so that you have the lines in the proper order) you may need to break the line into the constituent end points and then change the direction based on an attribute (e.g. 1 = start, 2 = end) - you can use this to conditionally connect only those points that are different (If 1 + 2 then create connecting lines).

If you're working with an IDE the code for doing this is quite lengthy, but I will do my best to help if you have specific questions.

  • 1
    "Unsplit Line" requires an ArcInfo license. If you do not have this license level then use "Dissolve", it has an Unsplit Line option. – klewis May 17 '13 at 22:20

I had to do exactly the same quite a while back using AV 3.x and Avenue. I had a quick look for the code but couldn't find it. If I remember correctly the logic went something like this: (I also had the bus stops and terminals as a different point shapefile so I was able to determine the start and end parts):

  1. Create an empty polyline to receive the sorted parts. Lets call it the 'sorted polyline'
  2. To get the first part:

    2a. Get the part that is closest to start terminal

    2b. Get the distances of the start and end node of this part to the start terminal. If the start vertex is the closest one add this part to the 'sorted polyline'. If its the end- FLIP it and then add it.

  3. To get the middle and end parts, start with the part (polyline) that you created in the previous step and within a while(true) loop, start comparing the distance between the end node of the first part to the other parts in the input polyline. The one that is closest is the 'next part'. Compare the distance of the start and end node of the next part to determine whether to flip it or not before adding it to the 'sorted polyline'
  4. Exit the loop when the number of part in the 'sorted polyline' is the same as in the input polyline.

... or something like that! :-)

Let me know if this makes sense to you and I can have another go finding my original Avenue code.


I worked in a project something similar of this, I used ArcObjects. My goal was connecting two adjacent polylines if one of it's end point is another one's starting point to make two short polylines into a single polyline. My process was:

1. Dictionary<PointKey, FeatureDataList> polylineDictionary;
  • PointKey is a class that contains a point.
  • FeatureDataList is a class that contains List of IFeatures.
  • Both classes overrides "Equals" and "GetHashCode" methods.

    Dictionary<PointKey, FeatureDataList> ToPointDictionary;
    Dictionary<PointKey, FeatureDataList> FromPointDictionary;
    public void CreateDictionary(IFeatureLayer featureLayer)
        var featureFunctionality = new FeatureFunctionality();
        List<IFeature> features = GetAllFeatures(featureLayer.FeatureClass);
        foreach (var feature in features)
            IPolyline polyline = GetPolylineFromFeature(feature);
            AddFeatureInDictionary(ToPointDictionary, feature, polyline.ToPoint);
            AddFeatureInDictionary(FromPointDictionary, feature, polyline.FromPoint);
    void AddFeatureInDictionary(Dictionary<PointKey, FeatureDataList> polylineDictionary, IFeature feature, IPoint point)
        FeatureDataList featureDataList;
        PointKey key = PointKey.GetKey(point);
        if (!polylineDictionary.ContainsKey(key))
            featureDataList = new FeatureDataList();
            polylineDictionary.Add(key, featureDataList);
            featureDataList = polylineDictionary[key];

By these processes I made two dictionaries. After creating dictionaries, I check for if both dictionaries contain same point and in both dictionaries, that key has only one feature in feature list, then I created a new polyline with those two polylines and delete two short polylines.

To join two polylines into one:

   private IPolyline GetJoinedPolylineFromFeatures(List<IFeature> features)
        IPolyline newPolyline = null;
        if (features.Count == 2)
            IPolyline polyline1 = feature1.Shape as IPolyline;
            IPolyline polyline2 = feature2.Shape as IPolyline;
            if (PointKey.GetKey(polyline1.ToPoint).Equals(PointKey.GetKey(polyline2.FromPoint)))
                var topoOperator2 = polyline1 as ITopologicalOperator2;
                if (topoOperator2 != null)
                    newPolyline = topoOperator2.Union(polyline2) as IPolyline;
            else if (PointKey.GetKey(polyline1.FromPoint).Equals(PointKey.GetKey(polyline2.ToPoint)))
                var topoOperator2 = polyline2 as ITopologicalOperator2;
                if (topoOperator2 != null)
                    newPolyline = topoOperator2.Union(polyline1) as IPolyline;
        return newPolyline;

I had exactly the same problem due to updates I made to bus routes using the "Reshape Feature" Tool. Dissolve, Merge and Unsplit were not working because the multipart features were not coincident.

If you haven't noticed this by now, take a closer look at the vertices that must coincide between your multipart features. Extend, trim or reshape as necessary and then use any of the tools stated above.

  • Oh, and by the way: By "closer look" I mean VERY VERY CLOSE. – Abraham L May 3 '16 at 19:17
  • 1
    I had the same problem and took a Much Much closer look at the part end vertices as Abraham suggests. They were, in fact, not connected. Turn on endpoint snapping and snap the end vertices together, problem solved.. for me anyhoo. – user80712 Aug 12 '16 at 21:55

protected by PolyGeo Aug 13 '16 at 0:05

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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