3

I am making a model which requires creating a grid and clipping various layers to it. Using the Create grid function does not provide an ID column, instead it creates 2 columns: "longitude" and "latitude".

Because of this, I would like the Modeler to insert a new ID column using either Field Calculator or Advanced Python Field Calculator but I have no idea what the expression is.

I am using QGIS 2.2.0 Valmiera.

I have noticed this topic: Auto-incrementing in Python Script with ArcPy cursor?

If using the Advanced Python Field Calculator, would the python coding be inserted to the Global expression or to the Formula?

3

Assuming you don't need a true, database-style auto-incrementing field (which would only work in PostGIS or Spatialite or another db data format), you could simply add a calculation step to your model, calculating an ID column with the expression:

$rownum

… this will give a unique, incremented set of integer values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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