QGIS: Unique identifier for a layer using Field Calculator

  • Software: QGIS 3.20
  • OS: Any
  • Updated August 2021

Sometimes you need to uniquely identify data. I have one client for which I generate points and those points must be unique.

Open your data in QGIS – in this example I have points that have been generated and fall within a boundary.

Open the attribute table and toggle editing mode on the point file.

There are two ways I have done this – one is using the Function $id and one is using the function @row_num. Both of these functions can be located under Record in the function list.

  • Create a new field called id
  • output field type integer
  • Default to 10 characters
  • Under expression enter @row_number

Click OK. You now have a unique attribute for your point file.

Want to add a Unique identifier with a character like ‘R’?

‘R’ || @row_number

Want QGIS Training? Need help with a project? Give us a shout at info at northrivergeographic.com