Field calculator has a great function under "Records" called "$rownum" which returns (assigns) the number of the current row.
Is there a way to make it work together with sorting? Lets say I want to sort table by column "length" and get the order (sequence) of lines by length from shortest to longest.
I know I can use some office spreadsheet software easily for this to sort by column and populate new column with order (sequence). But I would prefer to do the whole job in QGIS.
Update: As workaround there is also How to change the order of features in a shapefile? - using mmqgis plugin and function modify/sort and after that use "$rownum" on the new saved file.
Answer
So, I've coded a plugin (Sort and Number) to solve your issue. It allows you to select up to 3 fields and order your attribute table according to these fields. Then, it numbers the attribute table in a new field (named "order" by default), starting from 1.
No comments:
Post a Comment