4

I have a beautiful grid/polygon, each square having its own "ID", and several observations for each square. But, I have three categories of observation, each with its own row, matching the same "ID". Here "gid" and "id_carreau". I would like to have the three different "NUMCOUNTS" on the same row.

My final goal is to create a pie chart for square of the grid, proportional to these categories.

Here is my question, how do I merge these rows? see selected.

enter image description here

0
4

You could use the Aggregate Processing Toolbox (Vector geometry --> Aggregate). In "Group by expression" enter the gid field.

3

You can use "Merge Attributes of Selected Features" Tool to merge your rows.

enter image description here

1

In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume there is a point layer called 'grid_test' with it's attribute table, see image below.

input

With the following query, it is possible to achieve the result, i.e. to merge rows.

SELECT id, geometry AS geom,
       GROUP_CONCAT(attr1) AS attr1,
       GROUP_CONCAT(attr2) AS attr2,
       GROUP_CONCAT(attr3) AS attr3
FROM "grid_test"
GROUP BY id, geometry

The output Virtual Layer will look like as following

result


References:

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.