1

I have three layers in QGIS, each with one feature, including some attributes.

  • Layer 1 has attributes a, b, and c,
  • Layer 2 has attributes d, e, and f and
  • Layer 3 has attributes g, h, and i

I want to merge all three layers and keep all attribute values.

When I run "Dissolve", I get the values of attributes a, b, and c. The attributes from the other two layers are there, but with NULL values (the normal case after dissolve).

But what is the solution in QGIS to have one dissolved layer with one feature including all nine attributes with their respective values?

2

2 Answers 2

2

Create a virtual layer with this query and export/save it to make it permanent:

select a, b, c, d, e, f, g, h, i, 
st_union(layer1.geometry, st_union(layer2.geometry,layer3.geometry)) 
from layer1, layer2, layer3
2

The solution from @Babel will result in only one feature with 9 columns, if you want to have 3 features with 3 columns and attributes you have to use a union instead:

select * from Layer1
union
select * from Layer2
union
select * from Layer3
1
  • I was looking for the solution as proposed by @Babel. But yours is a useful additional hint.
    – winnewoerp
    Commented Jan 19 at 12:53

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.