Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

6 Answers 6

up vote 6 down vote accepted

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).
share|improve this answer
1  
Thanks. I only had a few lines to merge, so this was quick & easy. (@Michael Markieta's answer seemed better suited to complex situations.) –  Evan Jan 24 '12 at 19:44
add comment

You can accomplish this with a combination of QGIS and GRASS.

  1. Import your vector layer into a GRASS mapset ( Grass | File > Import Vector Data )
  2. Open your mapset in QGIS ( QGIS | Plugins > GRASS > Open mapset )
  3. Add vector layer from your GRASS mapset to your QGIS project ( QGIS | Plugins > GRASS > Add GRASS vector layer )
  4. Use v.clean.snap ( QGIS | Plugins > GRASS > Open GRASS tools > Modules List > v.clean.snap )

Adjust the v.clean.snap 'threshold' to attain proper vertex snapping throughout study area.

share|improve this answer
add comment

If you mean that your single feature consists out of a MULTILINESTRING instead of a single LINESTRING then you can easily fix that if you are using a Postgis database:

update your_table set your_geo_column = ST_LineMerge(your_geo_column);

If you only want the 1 row to do this you should add WHERE id = your_row_id of course.

share|improve this answer
add comment

I assume you are wanting to join two line segments into one line. enter image description here

This is how I did it ...

  • Enable editing.
  • Turn on snapping ( Settings -> Snapping Options ... ) enter image description here
  • Select the node node tool.enter image description here
  • Double click close to the end of one of the lines to add a node. enter image description here
  • Drag the node at the end to snap onto the the end of the other line enter image description here
  • Select both lines
  • Merge their attributes ( you cannot make therm one line if they have differing attributes)enter image description here
  • Merge the two featuresenter image description here

This should result in one line. enter image description here

share|improve this answer
add comment

Also someone could try:

  1. save .shp as .dxf
  2. open .dxf with DraftSight
  3. join polyline parts
  4. reopen .dxf with qgis and save as .shp
  5. from Vector menu -> Geometry tools -> Lines to polygons
share|improve this answer
add comment

Using OpenJUMP (Plus edition):

  1. File > Open file
  2. Plugins > Topology > Network topology cleaning ...
  3. Right click on the new layer (fixed): Save dataset as ....

This is the result: enter image description here

share|improve this answer
add comment

Your Answer

 
discard

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.