I have a large feature dataset with thousands of entries. Each entry is represented by a polygon. The most have unique values in all fields but some of them have to be merged based on a identity number in a field (zip code). I want to merge these polygons without losing the other field values. Is there a operation for this in QGIS?
1 Answer
You can use Menu Processing / Toolbox / Aggregate
for this. See the documentation: https://docs.qgis.org/3.16/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#aggregate
To keep all attribute values, you can concatenate them. This works well for string (text) fields. If you have integers, you must convert them to string using to_string("attribute")
(replace attribute
with the name of the respective attribute). Don't forget to set the resulting field-type to text and define a field-length long enough to include all values:
-
Thanks for the fast answer. I will check this tomorrow morning and post a update. Aug 12, 2021 at 19:43
-
I could need some help getting this to work. What function of aggregate would be the way to go to keep all the field values. There is a bunch (sum, concencate collect,...) of them and I am not very into these functions. Aug 13, 2021 at 7:34
-
Can you post a screenshot of your attribute table (or provide sample data)?– BabelAug 13, 2021 at 7:36
-
1What you added is the aggregate dialog window, not the attribute table. Never mind: see updated answer.– BabelAug 13, 2021 at 8:33
-
1You might split your layer into those with duplicates and those without and then apply the aggregation on only the duplicates. Then merge the two sets back together. This expression will get the duplicates: Count(1,"ID")>1 replacing ID with your zip code field– JohnAug 13, 2021 at 13:04