QGIS/C3/Table-Joins-and-Spatial-Joins/English-timed

From Script | Spoken-Tutorial
Revision as of 10:52, 15 September 2020 by PoojaMoolya (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Welcome to this tutorial on Table Joins and Spatial Joins in QGIS.
00:08 In this tutorial, we will learn to join the attribute tables of two data-sets having,

common field , and same spatial data

00:19 Here I am using

Ubuntu Linux OS version. 16.04

00:26 QGIS version 2.18
00:30 To follow this tutorial learner should be familiar with QGIS interface.
00:36 For the prerequisite QGIS tutorials, please visit this website.
00:42 Download the folder given in the Code files link, located below the player.
00:48 Extract the contents of the downloaded zip file and save it in a folder.
00:54 I have already downloaded the Code files, extracted and saved in a folder on the Desktop.
01:01 Double-click on the folder to open it.
01:04 Locate Stations.shp file in the extracted folder.
01:09 The Stations.shp file shows locations of meteorological stations or air stations across India.
01:17 Here we also have other files required to practice this tutorial.
01:23 Joining the attribute tables means, combining the attribute data between two data-sets.
01:30 There are two ways to join a table,

Table Join that is, joining tables having one or more common column data.

01:40 Spatial Join means joining tables having same spatial data.
01:46 In this tutorial we will be demonstrating both the methods.
01:50 For more information please visit this website.
01:54 Open QGIS interface.
01:57 First, we will join attribute tables having common field.
02:02 Click on Add Vector Layer tool from the toolbar on the left-side.
02:07 Add Vector Layer dialog box opens.
02:10 Click on Browse button next to Dataset field.

A dialog-box opens.

02:17 Navigate to Stations.shp file from the Code files folder on the Desktop.
02:22 Click on Open button.
02:25 In the Add vector layer dialog box, click on Open button.
02:30 The Stations.shp layer will be added in the Layers Panel.
02:35 The corresponding map appears on the canvas.
02:39 This map shows point features, corresponding to meteorological stations located in different states in India.
02:47 Let us open the attribute table for this layer.
02:51 In the Layers Panel, right-click on Stations.shp.
02:56 From the context menu choose Open Attribute Table option.
03:01 Attribute table opens.
03:03 Notice that data for only one attribute District is available.
03:10 Minimize the attribute table.
03:13 Now we will add another data-set which is a spreadsheet to the Layers Panel.

This data set is in CSV format.

03:23 Click on Layer menu on the menu bar.

Click on Add layer.

03:30 From the sub-menu click on Add Delimited Text Layer option.
03:35 A dialog box opens.
03:38 Click on Browse button located next to File Name field.
03:43 A dialog box opens.
03:46 Navigate to Rainfall.csv file from the Code files folder on the Desktop.

Click on Open button.

03:54 In the Delimited Text File dialog box, select CSV as File Format.
04:01 Select Geometry definition as No geometry.

Leave all other fields as such.

04:09 Click on OK button.
04:12 On QGIS canvas, Rainfall layer will be added in the Layers Panel.
04:18 Right-click on Rainfall layer.
04:21 Click on the Open Attribute Table from the context menu.
04:26 Attribute table opens.

The attribute table has rainfall data from January to December for various districts.

04:37 Maximize the Stations attribute table and compare both the tables.
04:43 Please note, the District field is common in both Rainfall and Stations layers.
04:50 Now we will add the attribute data from Rainfall layer to Stations layer.
04:56 In the Stations attribute table there is only one column named District.
05:02 We will add the Rainfall data to the Stations attribute table.
05:07 Close the attribute tables.
05:10 Select Stations layer in the Layers Panel.
05:14 This layer will receive the new data from the Rainfall layer.
05:19 Right-click on Stations layer.
05:22 Click on the Properties option from the context menu.
05:26 Layer Properties dialog box opens.

Click on Joins from the left panel.

05:33 In the new window, click on the plus sign, located on the bottom-left corner.
05:39 Add vector join dialog box opens.
05:43 Here we have options to choose for Join layer, Join field and Target field.
05:51 Join layer will be Rainfall layer, from which data will be added to Stations attribute table.
05:59 Here Rainfall layer is already selected.
06:03 Join field is the field or attribute in the Rainfall table to be joined.
06:10 In the Join field, select District from the drop-down.
06:15 Target field is the field to be joined in the Stations table.
06:20 In the Target field, District is already selected.
06:25 This field is common to both the tables.
06:29 Check the check-box for Choose which fields are joined.
06:34 The text-box below is now populated with all the columns and check-boxes.
06:41 Check the boxes for the columns January to Annual Average in the text box.
06:48 Click on OK button to close the Add vector join dialog box.
06:53 In Layer Properties dialog box, information about layer and columns joined are indicated at the top.
07:02 Click on Apply button, then OK button.
07:06 On the QGIS interface, as shown earlier open attribute table for Stations layer.
07:14 Observe that this table shows Rainfall data for all the stations.
07:20 Close attribute table.
07:23 Next, we will learn how to join attribute table of two data-sets by location.
07:30 Let us add another layer to the Layers Panel.
07:34 For this click on Add Vector Layer tool.
07:38 In the Add Vector Layer dialog box, click on Browse button.
07:43 Navigate to the Admin.shp from the Code files folder on the Desktop.
07:49 Click on Open button.
07:51 Again click on Open button in the Add Vector Layer dialog box.
07:56 Admin layer is now added to the Layers Panel.
08:00 Admin layer map opens showing the administrative state boundaries of India.
08:07 Click the Admin layer in the Layers panel.
08:11 Drag and bring it below Stations layer.
08:15 Now we can view the point features located in different States.
08:20 Open attribute table for Admin layer.
08:24 The attribute table shows information related to states.
08:29 Minimize the Admin attribute table.

Again open the Stations attribute table.

08:36 Now we will join the attributes by location for Stations layer and Admin layer.
08:43 Close both the attribute tables.
08:47 Click on Vector menu.
08:48 Scroll down the menu and click on Data Management Tools.
08:53 From the sub-menu select Join attributes by location.
08:58 Join attributes by location dialog box opens.
09:02 Click on the drop-down for Target vector layer.
09:05 Here we need to specify the target vector layer for joining the attribute table.
09:12 In our case we need to add new data to the Stations layer.
09:17 Hence Stations layer is the Target Layer.
09:21 So we will select Stations [EPSG: 4326] from the drop-down as target layer.
09:29 Click on the drop-down for Join vector layer.
09:33 Here we have to select the layer which we want to join with the target layer.
09:40 Select Admin [EPSG: 4326] from the drop-down.
09:45 Here we have several options for joining the attributes.
09:50 We are interested to find the meteorological stations located in various states.
09:56 So under Geometric predicate, we will select within check-box.

Scroll down.

10:04 Check the check-box for Open output file after running algorithm.
10:10 Leave the rest of the settings as default.

Click on the Run button.

10:17 Status bar at the bottom shows the progress of the processing algorithm.

Wait for the process to complete.

10:25 On the canvas, a new layer, Joined layer is added in the Layers Panel.
10:32 Right-click on the Joined layer and open attribute table.
10:37 This table contains all the attributes from Admin layer for each point on the Stations layer.
10:45 Every point feature has information about the state.
10:49 Close the attribute table.
10:52 To save the project, click on Project menu from the menu bar.

Select Save As option.

11:01 Give an appropriate name and select a convenient location.
11:06 Click on Save button.
11:10 Let us summarize.
11:12 In this tutorial we have learnt to join the attribute tables of two data-sets having,

common field, and same spatial data

11:22 As an assignment,

Join the rainfall data from June to December with the stations data.

11:30 Use Rainfall.csv and Stations.shp files given in the Code files folder.
11:37 The completed assignment should look like this.
11:41 This video summarizes the Spoken Tutorial project.

Please download and watch it.

11:48 The spoken tutorial project team conducts workshops and gives certificates.

For more information please write to us.

11:58 Please post your timed queries on this forum.
12:02 The Spoken Tutorial Project is funded by NMEICT, MHRD Government of India.
12:10 This tutorial is contributed by Ambadas Maske from College of Engineering Pune, Snehalatha Kaliappan and Himanshi Karwanje from IIT Bombay.

Thank you for joining.

Contributors and Content Editors

PoojaMoolya