The project has a layer with several groups of polygons with different weights. Each group is associated to a weight. How can I get the sum of the area of each group?

  • Is the weight of each group stored in its attribute table? Then your task would be as easy as intersecting the polygons, which will keep all atributes intact and then using the vector calculator to sum up the weights. – Kersten Jul 20 '15 at 15:24
  • If you have time or interest, load the polygons into SpatialLite - then you can use SQL operators and functions to solve this quite easily... otherwise you're using GUI's and intermediate data tables and this gets klunky... (PostGIS is ultimately a great solution too, but SpatialLite is a light-weight spatial database format that allows for SQL functions using spatial data) – DPSSpatial Jul 20 '15 at 16:46
  • Yes, the weight of each group is in the attribute table. So, really, the suggestion is very useful and easy. About SpatiaLite, I have a lot of interest but not now. – Sergio Jul 20 '15 at 22:04

You can use the GroupStats plugin to achieve your goals. Just make sure to add the area column to your data table. Here's a link to a tutorial for the plugin GroupStats

  • Excellent solution. The functions mentioned in plugin manager are very superficial and do not show the actual potential of the plugin. The tutorial is very good. The plugin could include mode (the value that appears most often in a set of data). – Sergio Jul 20 '15 at 22:25
  • 1
    Why the areas calculated by Qgis and by GroupStat are different? The areas calculated by GroupStat seem more correct the those calculated by Qgis. Would anybody explain what is happening? – Sergio Jul 22 '15 at 18:14
  • @Sergio Can you explain how you obtained the areas while using each method? – Techie_Gus Jul 23 '15 at 4:48

In case I understand correctly, the common attribute for your groups is a weight attribute?

Then you could use any of the dissolve functions in the toolbox, using that weight-field for dissolving (receiving probably multipart polygons). Next step would be to add a new area-field to your layer in the field calculator, using the $area expression to calculate the area for each group (now one polygon).

  • Yes, you understood correctly. Your suggestion is a good solution. – Sergio Jul 20 '15 at 22:08

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.