I know how to automatically assign numbers to a new point files using the $rownum function in the field calculator. However it does it from the top-left over and down like reading a book.

I could manually add the numbers myself that would be very time consuming in large point features.

What I'm wanting to do, as shown in the picture, is the top-left group of points to have them labeled 1 to 33 and the bottom-right group from 34 to the end.

Also, if I wanted to label the points vertically and start at the furthest top-left point and go down and then to the right, how would that be accomplished.

I'm sure that there is just some "code" I need to put into the field calculator but I do not know how.

enter image description here

3 Answers 3


$rownum is the row number and has absolutely nothing to do with how the features are arranged on the map.

You could select all points in the left polygon and calculate an id such as 100+$rownum and do the same with the right one but 200+$rownum. That won't result in consecutive ids, but depending on the use case it might be enough.


Two concepts might help:

  • Use the mmqgis plugin to label the points by hub. You would create a new layer which is the hub to the top left; or
  • Create an index of the points based on their x and y using the field calculator commands $x $y. And follow this up with some calculation and then rank/sort the result.

Obviously the detail is yours to find by trial and error.


I wanted to name the same method: As I can see, you could easily select features by rectangle here. Then in the attribute table you use the field calculator and use e.g. 34+$rownum, just as desired.Make sure to only update selected values by checking that box (only update selected features) above.This should work ok I think.


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.