mapping

Introduction to Mapping using QGIS

View the Project on GitHub dhsouthbend/mapping

«< Previous Next »>

Using the Field Calculator

Let’s open the Attributes Table of the Vulnerable Area layer. You will notice that this layer has the exact same attributes than the Blocks layer, but fewer features, because it only kept the features that were within the clipped area. Let’s look at the Pop2000 attribute. This one shows the total population per census block in 2000. What if we wanted to know the total population that lives in the vulnerable areas? To know this, the Field Calculator will be of use.

Field Calculator Window

The Field Calculator allows you to create a new field based on calculations done on other fields in the same table. It is important that you write a name for the new field and also that you select the type of data that will be contained in it. For example, if we are counting population, a Whole number (integer) type will suffice, but if we are calculating percentages, we might want to choose a Decimal Number (real) type of data. We can also choose the Precision, which determines the number of decimals that will be shown for a decimal number.

The Calculation is determined by the Expression you write. A basic expression would involve operators such as addition (+), substraction (-), division (/) and multiplication (*). To the right of the expression field, we have an organized list of all possible operations, functions and fields that can be used in expressions. To calculate the total population (let’s call the field TOTPOP), we will perform a sum of the Pop2000 field:

 sum(  "POP2000" )

Under the Expression box, we have the “output preview” which indicates whether the expression is valid or not. If you didn’t put the closing parentheses (or if there is any other error or typo), it will read “Expression is invalid”. Otherwise, the Output preview should show a number; this means the expression is valid.

«< Previous Next »>