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?

Taras
  • 32,823
  • 4
  • 66
  • 137
winnewoerp
  • 1,504
  • 11
  • 21
  • 1
    How I'd approch this: Union https://docs.qgis.org/3.28/en/docs/user_manual/processing_algs/qgis/vectoroverlay.html#union to get all the attributes together, add a new field and calculate it by appending attributes a to i with a pipe or similar delimiter then dissolve by that attribute to find your unique polygons, use polygon centroids to extract the centroid points from the unmerged polygons then spatial join https://www.qgistutorials.com/en/docs/performing_spatial_joins.html the centroids to the merged polygons to retrieve your attributes. – Michael Stimson Jan 19 '24 at 00:34
  • https://gis.stackexchange.com/questions/25061/merging-multiple-vector-layers-to-one-layer-using-qgis – Xeppit Jan 19 '24 at 00:39

2 Answers2

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
Babel
  • 71,072
  • 14
  • 78
  • 208
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
eurojam
  • 10,762
  • 1
  • 13
  • 27