Sunday, 6 March 2016

polyline creation - Merging lines with slightly different endpoints in QGIS


In QGIS, I have two lines. The endpoints are near each other, but not quite aligned. I'd like to turn the two lines into one, with the two endpoints merged into midpoints.


The closest I've been able to come is with "Merge selected features." That gives me one feature, but it's comprised of two disjoint lines -- there's no line between the endpoints.


I'm looking for something that behaves similarly to Illustrator's Join Paths feature (Object > Paths > Join).



Does QGIS do that?



Answer



Quick answer: no! There's no tool like that to do that operation directly on the layer (the "Join Two Lines" plugin requires intersection).


You could do it for a very simple layer by turning the lines to points (extract nodes) then joining with points2one (line output) but this would be MUCH slower than just editing by hand:



  1. Make sure you have snapping (Settings|Snapping options ...) turned on for your line layer (5 pixels works well for me).

  2. Create a new line from one endpoint to the other.

  3. Select all three lines (the two original lines + the new one) and merge them (Edit|Merge selected features or toolbar button).


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...