5

I'm trying to dissolve the fields "Inundation" and "EVC_BCS" (to get the areas of inundation and non-inundation for each rarity category). When I do the dissolve, I would also like to sum the field "AREASQM" as well.

I've tried using the Plugin "Dissolve with stats", but I've realised that I can only dissolve by one field (not two).

enter image description here

Thus, I'm quite stuck. How can I dissolve based on two fields whilst summing the "AREASQM" field?

2 Answers 2

4

Use Menu Processing / Toolbox / Aggregate, where you can set detailed conditions for

  1. which fields (based on what condition) should be merged
  2. how to deal which each field

For both, the full power of QGIS expressions can be used to generate complex conditions using multiple attributes.

enter image description here

2

There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume there is a polygon layer called 'grid_test' (red squares).

input

With the following query, it is possible to dissolve two fields while summing a third field.

SELECT GROUP_CONCAT("id") AS ids,
       SUM("AREASQM") AS SUM_AREASQM,
       ST_union(geometry) AS geom
FROM "grid_test"
GROUP BY "Inundation", "EVC_BCS"

Here the ST_Union() function was used.

The output polygon layer (yellow) with its attribute table will look like

result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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