Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a polyline shapefile containing a number of lines, some of which overlap. By overlap, I mean that they follow exactly the same path for some of their route, but also have bits that are not shared. As it's difficult to explain in words, the following images should help:



In the example above, you can see how the two selected lines overlap, and I want to merge them into one line feature.

Is there a way to do this with a built-in ArcGIS tool? If not, is there an easy way to check for overlapping in Python? (and then an easy way to merge two lines in python?)

share|improve this question
I also have an similar problem.......I have plenty of of lines to merge. IS there a proper solution to do it automatically – user4184 Sep 9 '11 at 23:08
up vote 6 down vote accepted

Dissolve Lines

update link (28th October 2014) Single Part & DISSOLVE_LINES enable in the geoprocessing tool.

share|improve this answer
Thanks - I'd never seen that. However, is it possible to do this without having any attributes that I can do the dissolve on? From reading the docs (for v10.0) it seems that UNSPLIT_LINES and SINGLE_PART won't work together, but the DISSOLVE_LINES option requires a field to dissolve on. – robintw Jan 24 '11 at 1:58
In answer to my own comment...yes it is - it seems to work fine. Thanks! – robintw Jan 24 '11 at 14:56
So you can tick your own answer. – Mapperz Jan 24 '11 at 15:12
This link no longer works – snowgage Oct 28 '14 at 20:51
@snowgage updated link – Mapperz Oct 29 '14 at 2:15

If you use an ArcEditor license you could start ArcCatalog and:

  1. make a personal Geodatabase.
  2. create a Feature Dataset in the Geodatabase.
  3. Import your Shapefile in the Feature Dataset.
  4. Create a Topology in the Feature Dataset.
  5. Set the Topology Rule "Must not overlap" for your Layer.
  6. Run the Topology Validation.
  7. Check the results in ArcMap - you need to add the Topology Error Layer.

This will markup all the overlapping lines.

Hope this helps you :-)

share|improve this answer
Thanks - that's very useful. However, I can't seem to see a way to force all the bits found as errors to be merged - that is, to merge the overlapping bits of the polylines. Do you have any idea how to do that? – robintw Jan 21 '11 at 12:51
Maybe you can use the errors to select the overlapping bits (select by location) and then export them to a seperat layer. Then you delete the overlapping bits in your (copy of) original layer. Then you make a Spatial Join from your overlapping layer to your original layer - hereby you get the attributes from your overlapping bits added to the other lines. Then you load the overlapping bits layer to your spatial joined layer. Now you can use the Dissolve tool in ArcToolbox to merge features with the same ID. I have not tried it, but I think it might work, if you understand my long explenation. – Steen Kjeldsen Jan 21 '11 at 13:36

To fix, turn on the Topology toolbar, start editing mode, and use the Error Inspector and Fix Topology Error Tool. There are other tools to help you on the toolbar as well.

share|improve this answer

In an editing session, you could select the line segments you want to merge, then select Merge from the Editor drop down menu. The dialog box that will pop up asks you which segment you want to merge the others into. Either select the segment you want, or if it doesn't matter just go with the default.

share|improve this answer

This function will remove overlapping lines and replace (not merge) each segment with one of the features:

def remove_overlapping(input_polyline, output_polyline, tolerance=0):
    """Identifies overlapping (portions of) of a polyline feature class and replaces with one feature."""

    overlapping_segments = ScratchPath + "\\Scratch.gdb\\overlapping_segments"
    # Tolerance defines "overlap."
    tolerance_expression = str(tolerance) + " Feet"
    # Cutout overlap portions.
    arcpy.Intersect_analysis(in_features=input_polyline, out_feature_class=overlapping_segments, join_attributes="ALL",cluster_tolerance=tolerance_expression,output_type="LINE")
    # Discard all but one feature.
    arcpy.DeleteIdentical_management(overlapping_segments, fields="Shape",xy_tolerance=tolerance_expression,z_tolerance="0")
    multipart_after_erase = ScratchPath + "\\Scratch.gdb\\multipart_after_erase"
    arcpy.Erase_analysis(input_polyline, overlapping_segments,multipart_after_erase, cluster_tolerance=tolerance_expression)
    # Break apart multipart features which might have been created when using erase.
    arcpy.MultipartToSinglepart_management(multipart_after_erase, output_polyline)
    # Put the remaining feature (after DeleteIdentical) back into the rest of the feature class.
    arcpy.Append_management(inputs=overlapping_segments, target=output_polyline, schema_type="NO_TEST", field_mapping="#")
share|improve this answer
are you able to provide some comments within the code? – TsvGis Sep 30 '15 at 8:20
I added a few comments in the code. – Lowry Oct 1 '15 at 21:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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