Working with attribute data
Vector datasets consist of points, lines or polygons representing the shape and location of each geographic feature. In addition, they also consist of attributes, which are used to describe the properties of each feature. This tutorial will explain the basics of viewing attribute data in QGIS and show you how to create your own attributes.
In this tutorial, we will use data from the BAG (Basisregistratie Adressen en Gebouwen) as an example of how to work with vector attribute data in different ways using QGIS. If you would like to obtain the same data, you can follow this tutorial.
The simplest way that you can view a feature's attributes is by using the "identify results" tool. This can be found in the vector toolbar, which is usually automatically displayed in the top section of the QGIS interface. With this tool, you can simply click on one of the features in your dataset and a window will pop up to list the feature's attributes.
For example, in the screenshot to the right, the tool was used to select the polygon representing the TU library. You can see that this feature was selected because it is highlighted in red. The pop-up window shows the attributes associated with this polygon. For instance, the building year (bouwjaar) is 1994, the status is building in use (pand in gebruik) and the function (gebruiksdoel) is education.
Opening the attribute table
If you want to view the attributes of all features in a dataset, you can open the attribute table. In order to do this, select the layer in the layers list to make it the active layer and then click on the "open attribute table" icon in the top section of the QGIS interface. This will open a table as a pop-up window. Each feature in the dataset is shown as a row in the table and each attribute as a column.
To select features, you can use the "select features by area or single click" tool. Simply click on a feature to select it or click and drag to select all features within a rectangular area. Features that have been selected will be highlighted in yellow. You can see how many features have been selected at the bottom left of the QGIS interface. Deselect features by clicking somewhere else on the map canvas or clicking the "deselect features" icon.
It is useful to be able to select specific features for many reasons. One is that it makes it easier to find those features in the attribute table. Selected features are highlighted in blue in the attribute table. You can make selected features show up in the first rows of the table by clicking the "move selection to top" icon.
Creating a new attribute
In order to create a new attribute, click on the "open field calculator" icon. You can access this at the top section of the QGIS interface, but also in the attribute table. Follow these steps:
Step 1: Fill in a name for the attribute you want to add.
Step 2: Choose an appropriate output field type. For instance, if the value of the attribute you are adding is a number that will have decimal places, choose "decimal number (real)" from the drop-down menu.
Step 3: Type an expression in the empty box.
- You can use the menu to the right to select different functions to construct your expression with.
- A useful function is $area, which can be used to calculate the area of each polygon.
- If your expression is successful you will see an output preview.
Step 4: Click OK and the attribute will be added to your dataset.
Step 5: Adding a new attribute will turn the layer into editing mode. Switch off editing mode by clicking the yellow pencil icon in the toolbar and save the changes you have made.
You will be able to find the attribute that you have added in the last column of the attribute table.
- Vector attribute data basics: https://docs.qgis.org/3.10/en/docs/gentle_gis_introduction/vector_attribute_data.html
- Tutorial on working with attributes: https://www.qgistutorials.com/en/docs/3/working_with_attributes.html
- Lesson on vector attribute data: https://docs.qgis.org/3.10/en/docs/training_manual/vector_classification/attribute_data.html
- Working with the field calculator: https://docs.qgis.org/3.10/en/docs/user_manual/working_with_vector/attribute_table.html#using-the-field-calculator
- setting coördinates in qgis https://www.youtube.com/watch?v=3W-608yX6_4
- BAG downloading buildings in qgis https://www.youtube.com/watch?v=MqWXCHH-fvc
- BAG calculating m2 per building: https://www.youtube.com/watch?v=vEWzi-GhWVA