“The field calculator lets you create new columns or update existing columns based on an expression.”
Behind every vector layer in QGIS you will find a data table (attribute table). The data in this table describe the attributes of each feature. Sometimes you would like to update the contents of a column or create a new column with contents that are calculated. QGIS provides a tool for doing this which will explore in this worksheet.
Goal: To manipulate data in the attribute table using the field calculator
Check your results
Does your map look something like the screenshot above?
ne_10m_admin_0_countries in ne.sqlite
The field calculator uses the QGIS expression system for the formulas used to update fields. Expressions are used in many places in QGIS, so it is worth getting familiar with the system. The expression editor provides a detailed list of available functions, and each function has helped with explanations and examples. The result from your expression should be suitable for the column you are calculating - for example if you have a date column, be sure that your expression calculates a date.
You can also combine columns in your expression for example: "column_a" * "column_b" would calculate the product of columns a and b.
Click here to download the sample data for the lesson.