2.3 Joining vector layers and table data

Next, we would like to join the table data containing the electricity consumption with the polygon layer of the buildings. First, we will right click on the layer to which we want to join attributes to, in our case it is the polygon layer of the buildings called here rosario_municipalb.shp. Once we right click on the layer we will select the last button called Properties and The Vector Properties Dialog window will open. This dialog provides general settings to manage the appearance of layer features in the map (symbology, labeling, diagrams), interaction with the mouse (actions, map tips, form design). It also provides information about the layer, this is a good opportunity to check what is our layer’s coordinate reference system (CRS), here we can see the layer is in The World Geodetic System 1984 (WGS84). (See 2.7 and 2.8) (The geographic layers in our QGIS project must be in the same CRS. For more information about CRS)

Layer Properties

Figure 2.7: Layer Properties

Layer Information

Figure 2.8: Layer Information

On the left side panel, we can see an option called Joins. Join is associating records in one table or layer with records in another table or layer through a common field, known as a key. The join between a table of data to a layer is based on the value of a field that can be found in both tables. The name of the field does not have to be the same, but the data type must be the same; you join numbers to numbers, strings to strings, and so on (for more information about data types).
To join between the rosario_municipalb layer and the Edificios_Publicos_Rosario we will click on the + sign on the bottom left and the Edit Vector Join window will open. In this window we can select the table or layer we would like to join attributes from and what would be the Join Field of that table or layer and which field is associated with the same key in the target layer or table. In addition, we can choose if we want to associate all fields in the target layer or table or choose specific ones, in our case we are interested joining only the Total Consumos field. Once we are done editing, we can click on the OK button and then see the join configuration, to apply it on the target layer, we click Apply on the bottom right. (See 2.9 and 2.10)


Figure 2.9: Join


Figure 2.10: Join

To make sure the field was added correctly we can open the Attribute Table of the rosario_municipalb layer and check that the column was indeed joined. (See 2.11 and 2.12)

Attribute Table

Figure 2.11: Attribute Table

Attribute Table

Figure 2.12: Attribute Table