I have a single feature layer with a lot of lines that mostly do not overlap exactly.

Now I'd like to merge section which are close to each other. Is there a way to do this?

enter image description here

I tried to simplify the issue in this screenshot. Best outcome would be, that the merged line would allow conclusions what lines were merged. For example a merged red and green line should have the attribute value "red&green".

  • 1
    What software are you using? If you're using ArcGIS either Snap or Integrate should get you fairly close. Be careful with integrate, it modifies an existing file so be sure you have a backup before using. If you're using QGIS this should help gis.stackexchange.com/questions/254788/… Sep 6, 2022 at 7:06
  • I am using QGIS and Arc GIS Pro. The results with Arc Gis' Snap are zick zack lines. And it doesn't merge the lines, so I still have lines overlapping each other. Integrate however, unfortunately, does no visual changes. I am currently trying the QGIS approach with buffering and building the medial axis with PostGIS. As I am not into PostGIS I struggle to get a result here, too. Sep 6, 2022 at 7:51
  • If you use the buffers approach, there is a QGIS plugin called HCMGIS which has a centerline tool and there is a GRASS v.centerline tool. I haven't used either. If you use a clean or snap approach you should try different sized tolerances and other settings (e.g. behavior settings in the QGIS Snap geometries to layer tool. If you use a raster approach you can visually widen your layers symbols to "merge" prior to further work such as exporting to tif then using Arcscan to get vector lines from it, or raster to line tools in either program.
    – John
    Sep 6, 2022 at 14:10

1 Answer 1


All the mentioned tools can be found in Menu Processing > Toolbox:

  1. Create Line intersections: you get a point layer where the lines cross.

  2. Connect the points using Points to path.

    For order expression, enter line_locate_point (geometry (get_feature_by_id ('line', 1)), $geometry) where line is the name of your line layer and 1 is the feature number of one of the lines.

  3. Delete the intersecting lines to keep only the straight line from step 2: run Split with Lines, select the features in the region where they intersect and delete them.

    If you want, merge the two layers (result from step 2 and 3).

Initial lines: red and blue; result: yellow; Line intersection points (step 1): white dots: enter image description here

  • Thanks for your answer! I have trouble getting point 2 to work. What do you mean by "feature number of one of the lines"? Sep 6, 2022 at 7:46
  • This is a new approach to me and it looks promising for weaving lines. Lines that are more offset and separate for long distances than intersecting/weaving may need further work?
    – John
    Sep 6, 2022 at 14:14
  • @MrSalamikuchen each Line (feature) has a unique ID. This makes it possible to identify the line. If you want to know what ID a Line has, use QGIS expression $id - e.g. in field calculator or as label.
    – Babel
    Sep 6, 2022 at 18:30
  • @johns it depends in the result you expect. In principle, it should work
    – Babel
    Sep 6, 2022 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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