0

I have several layers (shapefiles) that have data in groups. Each group has a distinct group name. I am trying to number each item in the layer based on its distinct group name.

So, for each group I want to add a serial number for each object. For example group "broadst" = 1....7, group "crew" = 1......6 and so on.

Attribute Table

Manually this can be done by sorting and selecting each group and adding a sequential number using rownumber. But I have a large dataset and it will take a long time. Is there a plugin or would it be possible to use the field calculator using some form distinct filter based on group name?

user2856
  • 65,736
  • 6
  • 115
  • 196
mapperx
  • 1,427
  • 3
  • 13
  • 31
  • I am working with thousands of groups. The method in the solution would require manually typing each group name for each case and this would be time consuming. – mapperx Oct 06 '18 at 04:48
  • The accepted solution proposes to use the Add Autoincrement field from the processing toolbox and this should work just fine. I tested it and it works. – Techie_Gus Oct 06 '18 at 05:18
  • @Techie_Gus the Add Autoincrement field from the processing toolbox just adds numbers, it does not use any field attributes as a criteria for numbering each group. This is similar to rownumber from the field calculator. If you were able to number using distinct attribute values could you please show me the steps you followed. – mapperx Oct 06 '18 at 15:05
  • You need to select the attribute to categorize by under Group values by (Optional). If this still doesn't work, let me know so I can add a couple screenshots. – Techie_Gus Oct 06 '18 at 15:29
  • @Techie_Gus It does not give the option to choose a field. I am using version 2.18.16. The options from the algorithm window are Input layer and Incremented. – mapperx Oct 06 '18 at 16:31
  • 1
    Apologies for not noticing QGIS version in the title. I was referring to QGIS 3.2.3. Indeed QGIS 2.18.x does not offer the group by values option. – Techie_Gus Oct 07 '18 at 06:39

0 Answers0