[GIS] Dissolving shapefile but retaining a list of original attribute value in QGIS

dissolveqgis

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

Best Answer

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

concatenate()

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.