How can I dissolve a polygon layer in QGIS based on a single attribute but keep all (or some) other attributes at the same time? This is how I want to retain fields:

There are at least two fields I want to retain the information from in the dissolved shapefile, one is a string, the other one is numerical.

I would like to dissolve the shapefile based on the field "Class", and I want to retain the information of columns "Object_ID" and "Signal_species"

enter image description here


It is now more than one year from your post... From QGIS 2.16, new Aggregates functions became available. One of the new expression is concatenate().

Your Sample

enter image description here


Open the attribute table and create a new text field (with enough string length), with expression:

# Object_ID  -> O_IDs 
concatenate(  "Object_ID" , group_by:= "Class", concatenator:= ', ' )

# Signal_Sp  -> Signals
concatenate( to_string("Signal_Sp"), group_by:= "Class", concatenator:= ', ' )

Please note concatenate() takes only texts (strings), so I had to apply to_string() to "Signal_Sp" which was integer type...

After concatenate() your attribute table will become like below:

enter image description here

Now we can dissolve the polygon keeping original attribute data.

enter image description here

I will need to delete old fields (Object_ID and Signal_Sp) afterwards.

| improve this answer | |
  • This worked for me but it was extremely slow (almost an hour) to do a concatenation on a table with about 4500 rows. Does anyone have any idea why? It seems like this should be nearly instantaneous to me. QGIS version is 3.10 – wfgeo Sep 15 at 9:23
  • @wfgeo Could this be of help? – Kazuhito Sep 15 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.