Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm very new to QGIS, so forgive this simple question. Searching in older topics didn't help either. So:

I make a new column in my attribute table and it has a default value (for example 0). I want to (probably using the field calculator) have the result that row 1 has the value 1, row 2=2 and so on, just like a numbered index.

I'd be thankful for a code example for the field calculator (including the use of $rownum (I think I need this for switching to the line)).

share|improve this question
up vote 22 down vote accepted

Just put $rownum as the expression. Simple as that. :)

share|improve this answer
thanks!:)so simple actually. – Shepherdjo Jun 19 '12 at 12:31
Don't forget to mark it as the accepted answer. – Nathan W Jun 19 '12 at 12:42
Did it. thanks for the hint! – Shepherdjo Jun 19 '12 at 12:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.