1

I have a Shapefile with a road network (lines) which includes several road segments (lines).

Is there any way to merge all these lines into one line using QGIS?

4
  • 4
    Yeah, it's called "dissolve".
    – Erik
    May 13, 2019 at 11:17
  • Would you like to merge road segments via a specific parameter or just simply all in one? Do you need to preserve any attributes?
    – Taras
    May 13, 2019 at 11:39
  • 1
    I just want to merge the lines so I used "dissolve" as Erik suggested. It worked fine.
    – nat
    May 13, 2019 at 12:21
  • Nice to hear that 😊
    – Taras
    May 13, 2019 at 12:44

1 Answer 1

3

Tested on QGIS 2.18 and QGIS 3.4

I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume we have seven features in "roads", see image below.

Example

With the following Query, it is possible to achieve the result

SELECT COUNT(*) AS features,
       ST_Union(r.geometry)
FROM roads as r

The output Virtual Layer will create one continuous layer out of all road segments' geometries and additional field 'features' which will count how many features were merged.

Output

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.