TransWikia.com

How to group and count attribute data?

Geographic Information Systems Asked by Seren on March 23, 2021

I want to group and count features with the same code attribute value.

I can classify the data and enable feature count in the layer list but I cannot get counts in the attribute table.

5 Answers

I suggest you to install Group Stats plugin. Here is a quick tutorial: group stat tutorial

  1. Search for the Group Stats icon
  2. Select the layer in which you have the Codes
  3. Select the attribute (in your case Code)
  4. Click on Calculate

The Count will appear. If you go to preferences you should be able to select only Count avoiding the other parameters to be displayed (this is not my case...). Remember before click Save button you have to select the fields you want to add to your .csv: hold on Shift for do that. Here is a more advanced tutorial written by Anita Graser.

Answered by G M on March 23, 2021

you could also use Qspatialite in QGIS. The SQL window is just as Mapinfo one. Up to you after to make your SQL request with a groupby command on the wanted column.

Answered by BAUDIN on March 23, 2021

This was the best result on Google I could find, but the screenshot tutorial by G M is out of date and it took me a while to work out how to use the plugin.

  1. Once installed, Load the Group Stats control panel from the "Vector" menu.
  2. Select the layer of interest.
  3. From the fields list, drag the field of interest into the "rows" box.
  4. Now drag the same field into the "value" box.
  5. In the fields list are also some functions, drag "count" into the "value" box (below the field you put in there).
  6. Click "calculate" and a table will appear on the left.
  7. You can sort by the count if you wish, click the column label.

How this helps other people.

Answered by Gregory on March 23, 2021

With the new virtual layer you can now use SQL on any layer in QGIS, for example the airport Shapefile from the QGIS sample data:

enter image description here

To count the number of airports by USE type and compute the average elevation use:

enter image description here

The results are loaded as a new layer:

enter image description here

Answered by underdark on March 23, 2021

QGIS 3.10 comes with a "Statistics by categories" tool in the processing toolbox.

Statistics by Categories in QGIS

This is the result:

enter image description here

Answered by Stefan on March 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP