Difference between revisions of "QGIS/C3/Table-Joins-and-Spatial-Joins/English"
PoojaMoolya (Talk | contribs) |
|||
(10 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
{|border=1 | {|border=1 | ||
|| '''Visual Cue''' | || '''Visual Cue''' | ||
Line 8: | Line 6: | ||
'''Title Slide''' | '''Title Slide''' | ||
− | ||Welcome to this tutorial on '''Table Joins and Spatial Joins '''in QGIS. | + | ||Welcome to this tutorial on '''Table Joins''' and '''Spatial Joins''' in '''QGIS'''. |
|- | |- | ||
Line 14: | Line 12: | ||
'''Learning Objectives''' | '''Learning Objectives''' | ||
− | || In this tutorial, we will learn to join the '''attribute tables''' of two | + | || In this tutorial, we will learn to join the '''attribute tables''' of two '''data-sets''' having, |
− | * common field (Table Join), and | + | * common field '''(Table Join)''', and |
− | * same spatial data (Spatial Join) | + | * same '''spatial data (Spatial Join)''' |
|- | |- | ||
Line 26: | Line 24: | ||
|| Here I am using | || Here I am using | ||
− | '''Ubuntu Linux '''OS version. 16.04 | + | '''Ubuntu Linux''' OS version. 16.04 |
'''QGIS '''version 2.18 | '''QGIS '''version 2.18 | ||
Line 50: | Line 48: | ||
|- | |- | ||
− | ||Show the map '''Stations.shp''' on | + | ||Show the map '''Stations.shp''' on '''Desktop'''. |
− | || I have already downloaded the | + | || I have already downloaded the '''Code files''', extracted and saved in a folder on the '''Desktop'''. |
− | + | ||
− | extracted and saved in a folder on the | + | |
|- | |- | ||
− | || Double click on | + | || Double click on '''Code files''' folder. |
Point to '''Stations.shp'''. | Point to '''Stations.shp'''. | ||
Line 76: | Line 72: | ||
'''About Table Joins''' | '''About Table Joins''' | ||
− | || Joining the '''attribute''' | + | || Joining the '''attribute tables''' means, combining the '''attribute data''' between two '''data-sets'''. |
− | + | ||
− | combining the attribute data between two | + | |
|- | |- | ||
|| '''Slide Number 7''' | || '''Slide Number 7''' | ||
Line 85: | Line 79: | ||
'''https://www.gislounge.com/working-with-tables-mastering-qgis/''' | '''https://www.gislounge.com/working-with-tables-mastering-qgis/''' | ||
− | || There are | + | || There are two ways to join a table, |
− | 1. Table Join that is joining tables having one or more common column data. | + | 1. '''Table Join''' that is, joining '''tables''' having one or more common column '''data'''. |
− | 2. Spatial Join means joining tables having same spatial data | + | 2. '''Spatial Join''' means joining '''tables''' having same '''spatial data'''. |
− | In | + | In this tutorial we will be demonstrating both the methods. |
For more information please visit this website. | For more information please visit this website. | ||
Line 101: | Line 95: | ||
|- | |- | ||
|| Cursor on the interface. | || Cursor on the interface. | ||
− | ||First, we will join attribute tables | + | ||First, we will join '''attribute tables''' having common field. |
|- | |- | ||
|| Click on '''Add Vector Layer''' tool. | || Click on '''Add Vector Layer''' tool. | ||
− | ||Click on '''Add Vector Layer''' tool from the | + | ||Click on '''Add Vector Layer''' tool from the toolbar on the left-side. |
|- | |- | ||
− | || '''Add Vector Layer''' | + | || '''Add Vector Layer''' dialog box open. |
− | Click on '''Browse''' | + | Click on '''Browse''' button. |
Navigate to '''Stations.shp''' file. | Navigate to '''Stations.shp''' file. | ||
− | || '''Add Vector Layer''' | + | || '''Add Vector Layer''' dialog box opens. |
Click on '''Browse''' button next to '''Dataset''' field. | Click on '''Browse''' button next to '''Dataset''' field. | ||
− | A dialog-box opens | + | A dialog-box opens. |
− | Navigate to '''Stations.shp''' file from the | + | |
+ | Navigate to '''Stations.shp''' file from the '''Code files''' folder on the '''Desktop'''. | ||
|- | |- | ||
− | ||Click on '''Open''' | + | ||Click on '''Open''' button. |
||Click on '''Open''' button. | ||Click on '''Open''' button. | ||
|- | |- | ||
− | || '''Add vector Layer | + | || '''Add vector Layer dialog''' box will open. |
Click on '''Open.''' | Click on '''Open.''' | ||
− | || In the '''Add vector | + | || In the '''Add vector layer''' dialog box, click on '''Open''' button. |
− | + | ||
− | click on '''Open''' button | + | |
|- | |- | ||
− | || Cursor on ''' | + | || Cursor on '''Layers panel'''. |
Cursor on the map. | Cursor on the map. | ||
− | || The '''Stations.shp''' | + | || The '''Stations.shp layer''' will be added in the '''Layers Panel'''. |
The corresponding map appears on the canvas. | The corresponding map appears on the canvas. | ||
Line 144: | Line 137: | ||
|| This map shows point features, corresponding to meteorological stations located in different states in India. | || This map shows point features, corresponding to meteorological stations located in different states in India. | ||
− | Let us open the attribute table for this layer. | + | Let us open the '''attribute table''' for this '''layer'''. |
− | In the '''Layers Panel''', right-click on '''Stations.shp''' . | + | In the '''Layers Panel''', right-click on '''Stations.shp'''. |
|- | |- | ||
|| Click on '''Open Attribute Table''' option. | || Click on '''Open Attribute Table''' option. | ||
Line 152: | Line 145: | ||
|- | |- | ||
− | || Cursor on the Attribute table window. | + | || Cursor on the '''Attribute''' table window. |
|| '''Attribute table '''opens. | || '''Attribute table '''opens. | ||
− | Notice that data for only one attribute '''District '''is available. | + | Notice that '''data''' for only one attribute '''District ''' is available. |
|- | |- | ||
− | || Click on the minimize button on the top-left corner of the | + | || Click on the minimize button on the top-left corner of the '''Stations table.''' |
− | ||Minimize the attribute table. | + | ||Minimize the '''attribute table'''. |
|- | |- | ||
− | ||Click on | + | ||Click on '''Layers''' menu from the menu bar. |
− | || Now we will add another''' | + | || Now we will add another''' data-set''' which is a spreadsheet to the '''Layers Panel'''. |
− | This | + | This data set is in '''CSV''' '''format'''. |
|- | |- | ||
Line 176: | Line 169: | ||
|| Click on '''Layer''' menu on the menu bar. | || Click on '''Layer''' menu on the menu bar. | ||
− | Click on''' Add layer''' | + | Click on''' Add layer'''. |
From the sub-menu click on '''Add Delimited Text Layer''' option. | From the sub-menu click on '''Add Delimited Text Layer''' option. | ||
|- | |- | ||
− | || '''Create a layer from Delimited Text File''' | + | || '''Create a layer from Delimited Text File''' dialog box open. |
Click on '''Browse''' Button. | Click on '''Browse''' Button. | ||
− | || A | + | || A dialog box opens. |
Click on '''Browse''' button located next to '''File Name '''field. | Click on '''Browse''' button located next to '''File Name '''field. | ||
Line 193: | Line 186: | ||
Click on '''Open''' Button. | Click on '''Open''' Button. | ||
− | || A dialog | + | || A dialog box opens. |
− | Navigate to '''Rainfall.csv''' file from the | + | Navigate to '''Rainfall.csv''' file from the '''Code files''' folder on the '''Desktop'''. |
Click on '''Open''' button. | Click on '''Open''' button. | ||
|- | |- | ||
− | || Cursor on '''Delimited Text File ''' | + | || Cursor on '''Delimited Text File '''dialog''' '''box. |
Select '''CSV '''as''' File Format'''. | Select '''CSV '''as''' File Format'''. | ||
− | || In the '''Delimited Text File ''' | + | || In the '''Delimited Text File '''dialog box, select ''' CSV''' as''' File Format.''' |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|| Click on the '''No geometry (attribute only table)'''. | || Click on the '''No geometry (attribute only table)'''. | ||
− | || Select '''Geometry definition''' as '''No geometry .''' | + | || Select '''Geometry definition''' as '''No geometry.''' |
Leave all other fields as such. | Leave all other fields as such. | ||
|- | |- | ||
− | || Click on '''OK''' | + | || Click on '''OK''' button. |
− | ||Click on '''OK''' | + | ||Click on '''OK''' button. |
|- | |- | ||
− | ||Cursor on ''' | + | ||Cursor on '''Layers panel'''. |
− | ||On '''QGIS''' canvas, '''Rainfall ''' | + | ||On '''QGIS''' canvas, '''Rainfall layer''' will be added in the '''Layers Panel'''. |
|- | |- | ||
|| Cursor on '''Rainfall.csv''' Layer. | || Cursor on '''Rainfall.csv''' Layer. | ||
− | Click | + | Click on the '''Open Attribute Table from '''context menu. |
− | || Right-click on '''Rainfall''' | + | || Right-click on '''Rainfall layer'''. |
− | Click on the '''Open Attribute Table '''from | + | Click on the '''Open Attribute Table '''from the context menu. |
|- | |- | ||
− | ||Point towards the attribute table columns. | + | ||Point towards the '''attribute''' table columns. |
− | || '''Attribute table''' opens | + | || '''Attribute table''' opens. |
− | The | + | The '''attribute table''' has rainfall data from '''January''' to '''December''' for various districts. |
|- | |- | ||
||Cursor on the tables. | ||Cursor on the tables. | ||
− | ||Maximize the Stations attribute table and compare both the tables. | + | ||Maximize the '''Stations attribute table''' and compare both the '''tables'''. |
|- | |- | ||
||Point to '''District''' field in both the tables. | ||Point to '''District''' field in both the tables. | ||
− | ||Please note, the '''District '''field is common in both '''Rainfall '''and '''Stations''' | + | ||Please note, the '''District '''field is common in both '''Rainfall '''and '''Stations layers'''. |
|- | |- | ||
Line 248: | Line 238: | ||
Cursor on the station layer. | Cursor on the station layer. | ||
− | ||Now we will add the attribute data from''' Rainfall''' | + | ||Now we will add the '''attribute data''' from''' Rainfall layer''' to''' Stations layer'''. |
|- | |- | ||
|| Cursor on the first column of the '''Attribute table''' . | || Cursor on the first column of the '''Attribute table''' . | ||
− | || In the '''Stations''' | + | || In the '''Stations attribute table''' there is only one column named '''District'''. |
− | We will add the | + | We will add the '''Rainfall data''' to the '''Stations attribute table'''. |
|- | |- | ||
|| Click on '''x''' button on the top-left corner of the table. | || Click on '''x''' button on the top-left corner of the table. | ||
− | ||Close the attribute tables. | + | ||Close the '''attribute tables'''. |
|- | |- | ||
Line 265: | Line 255: | ||
Cursor on '''Stations''' layer. | Cursor on '''Stations''' layer. | ||
− | || Select '''Stations''' | + | || Select '''Stations layer''' in the '''Layers Panel'''. |
− | This layer will receive the new data from the '''Rainfall''' | + | This '''layer''' will receive the new '''data''' from the '''Rainfall layer'''. |
|- | |- | ||
Line 274: | Line 264: | ||
Click on the '''Properties''' option from context menu. | Click on the '''Properties''' option from context menu. | ||
− | || Right click on '''Stations''' | + | || Right-click on '''Stations layer'''. |
Click on the '''Properties''' option from the context menu. | Click on the '''Properties''' option from the context menu. | ||
|- | |- | ||
− | || '''Layer Properties''' | + | || '''Layer Properties''' dialog box will open. |
Click on''' Joins '''from the left panel. | Click on''' Joins '''from the left panel. | ||
− | || '''Layer Properties''' | + | || '''Layer Properties''' dialog box opens. |
Click on '''Joins''' from the left panel. | Click on '''Joins''' from the left panel. | ||
Line 295: | Line 285: | ||
|| In the new window, click on the '''plus '''sign, located on the bottom-left corner. | || In the new window, click on the '''plus '''sign, located on the bottom-left corner. | ||
− | '''Add | + | '''Add vector join''' dialog box opens. |
|- | |- | ||
|| Cursor on the options. | || Cursor on the options. | ||
− | || Here we have options to choose for | + | || Here we have options to choose for '''Join layer''', '''Join field''' and '''Target field'''. |
− | + | ||
− | '''Join | + | |
|- | |- | ||
||Cursor on '''Join layer''' field. | ||Cursor on '''Join layer''' field. | ||
− | || '''Join layer''' will be '''Rainfall''' | + | || '''Join layer''' will be '''Rainfall layer''', from which '''data''' will be added to '''Stations attribute table'''. |
− | Here '''Rainfall''' | + | Here '''Rainfall layer''' is already selected. |
|- | |- | ||
− | || Click on the '''Join | + | || Click on the '''Join field'''. |
− | Cursor on the '''Join | + | Cursor on the '''Join field'''. |
Select '''Districts.''' | Select '''Districts.''' | ||
− | || '''Join field''' is the field or attribute in the '''Rainfall table''' to be joined. | + | || '''Join field''' is the field or '''attribute''' in the '''Rainfall table''' to be joined. |
− | In the '''Join | + | In the '''Join field''', select '''District''' from the drop-down. |
|- | |- | ||
Line 323: | Line 311: | ||
Cursor on the '''District'''. | Cursor on the '''District'''. | ||
− | || '''Target field''' is the field to be joined in the '''Stations''' | + | || '''Target field''' is the field to be joined in the '''Stations table'''. |
− | In the '''Target field''', '''District '''is already selected. | + | In the '''Target field''', '''District''' is already selected. |
− | This field is common to both the tables. | + | This field is common to both the '''tables'''. |
|- | |- | ||
Line 334: | Line 322: | ||
Scroll down the slider to see all the check-boxes. | Scroll down the slider to see all the check-boxes. | ||
− | || Check the check-box for '''Choose which fields are | + | || Check the check-box for '''Choose which fields are joined'''. |
The text-box below is now populated with all the columns and check-boxes. | The text-box below is now populated with all the columns and check-boxes. | ||
Line 344: | Line 332: | ||
|| Check the boxes for the columns '''January''' to '''Annual Average '''in the text box. | || Check the boxes for the columns '''January''' to '''Annual Average '''in the text box. | ||
− | Click on ''' OK''' button to close the''' Add vector join '''dialog | + | Click on ''' OK''' button to close the '''Add vector join ''' dialog box. |
|- | |- | ||
− | || | + | || Dialog box will open. |
Click on '''Apply''' button >>'''OK'''. | Click on '''Apply''' button >>'''OK'''. | ||
− | || In''' Layer Properties '''dialog | + | || In''' Layer Properties '''dialog box, information about layer and columns joined are indicated at the top. |
− | information about layer and columns joined are indicated at the top. | + | |
Click on '''Apply''' button, then '''OK '''button. | Click on '''Apply''' button, then '''OK '''button. | ||
Line 358: | Line 345: | ||
|| Cursor on '''QGIS ''' Interface. | || Cursor on '''QGIS ''' Interface. | ||
− | Cursor on the ''' | + | Cursor on the '''Layers Panels'''. |
Right Click on '''Stations layer'''. | Right Click on '''Stations layer'''. | ||
− | || On the '''QGIS''' interface | + | || On the '''QGIS''' interface, as shown earlier open '''attribute table''' for '''Stations layer'''. |
− | + | ||
− | + | ||
|- | |- | ||
|| Select '''Open attribute table'''. | || Select '''Open attribute table'''. | ||
− | ||Observe that this table shows | + | ||Observe that this '''table''' shows '''Rainfall data''' for all the stations. |
|- | |- | ||
|| Click on '''x''' button on top-left corner of '''Stations''' layer. | || Click on '''x''' button on top-left corner of '''Stations''' layer. | ||
− | ||Close attribute table. | + | ||Close '''attribute table'''. |
|- | |- | ||
Line 378: | Line 363: | ||
Point to the '''Layers panel'''. | Point to the '''Layers panel'''. | ||
− | || Next, we will learn how to join attribute table of two | + | || Next, we will learn how to '''join attribute table''' of two '''data-sets''' by location. |
− | Let us add another layer to the '''Layers Panel'''. | + | Let us add another '''layer''' to the '''Layers Panel'''. |
|- | |- | ||
Line 390: | Line 375: | ||
Navigate to the '''Admin.shp''' | Navigate to the '''Admin.shp''' | ||
− | || In the '''Add Vector Layer''' dialog | + | || In the '''Add Vector Layer''' dialog box, click on '''Browse''' button. |
− | Navigate to the '''Admin.shp''' from the | + | Navigate to the '''Admin.shp''' from the '''Code files''' folder on the '''Desktop'''. |
|- | |- | ||
Line 399: | Line 384: | ||
|- | |- | ||
− | || Click on '''Open '''button in '''Add Vector Layer''' dialog | + | || Click on '''Open '''button in '''Add Vector Layer''' dialog box. |
− | Point to the '''Admin''' layer in the ''' | + | Point to the '''Admin''' layer in the '''Layers panel'''. |
− | || Again click on '''Open''' button in the '''Add Vector Layer''' dialog | + | || Again click on '''Open''' button in the '''Add Vector Layer''' dialog box. |
'''Admin layer''' is now added to the '''Layers Panel'''. | '''Admin layer''' is now added to the '''Layers Panel'''. | ||
Line 409: | Line 394: | ||
|- | |- | ||
||Cursor on the map. | ||Cursor on the map. | ||
− | ||'''Admin layer''' map opens showing the | + | ||'''Admin layer''' map opens showing the administrative state boundaries of India. |
|- | |- | ||
− | || Click | + | || Click the '''Admin layer''' in the '''Layers panel'''. |
Drag and bring it below station layer. | Drag and bring it below station layer. | ||
Line 418: | Line 403: | ||
Cursor on the map. | Cursor on the map. | ||
− | || Click | + | || Click the '''Admin layer''' in the '''Layers panel'''. |
− | Drag and bring it below | + | Drag and bring it below '''Stations layer'''. |
Now we can view the point features located in different States. | Now we can view the point features located in different States. | ||
Line 433: | Line 418: | ||
|| Cursor on the '''attribute''' table. | || Cursor on the '''attribute''' table. | ||
− | Minimize the '''Admin''' | + | Minimize the '''Admin attribute table'''. |
− | Open '''Stations''' | + | Open '''Stations attribute table'''. |
− | || The attribute table shows information related to states. | + | || The '''attribute table''' shows information related to states. |
− | Minimize the '''Admin''' | + | Minimize the '''Admin attribute table'''. |
− | Again open the '''Stations''' | + | Again open the '''Stations attribute table'''. |
− | Now we will join the attributes by location for ''' | + | Now we will join the '''attributes''' by location for '''Stations layer''' and '''Admin layer'''. |
|- | |- | ||
||Cursor on '''map'''. | ||Cursor on '''map'''. | ||
− | ||Close both the attribute tables. | + | ||Close both the '''attribute tables'''. |
|- | |- | ||
Line 452: | Line 437: | ||
|| Click on '''Vector''' menu. | || Click on '''Vector''' menu. | ||
− | Scroll down the menu and click on '''Data Management Tools''' | + | Scroll down the menu and click on '''Data Management Tools'''. |
− | From the sub-menu select | + | From the sub-menu select '''Join attributes by location'''. |
|- | |- | ||
||Cursor on '''Join attribute by location'''. | ||Cursor on '''Join attribute by location'''. | ||
− | ||'''Join attributes by location''' dialog | + | ||'''Join attributes by location''' dialog box opens. |
|- | |- | ||
||Cursor on '''Target vector layer'''. | ||Cursor on '''Target vector layer'''. | ||
− | ||Click on the drop-down for '''Target | + | ||Click on the drop-down for '''Target vector layer'''. |
|- | |- | ||
Line 468: | Line 453: | ||
Select '''Stations[EPSG: 4326]'''. | Select '''Stations[EPSG: 4326]'''. | ||
− | || Here we need to specify the target vector layer for joining the attribute table. | + | || Here we need to specify the '''target vector layer''' for joining the '''attribute table'''. |
− | In our case we need to add new | + | In our case we need to add new '''data''' to the '''Stations layer'''. |
Hence '''Stations layer''' is the '''Target Layer'''. | Hence '''Stations layer''' is the '''Target Layer'''. | ||
− | So we will | + | So we will select''' Stations [EPSG: 4326]''' from the drop-down as '''target layer'''. |
|- | |- | ||
Line 480: | Line 465: | ||
Select '''Admin [EPSG: 4326]''' from the drop-down. | Select '''Admin [EPSG: 4326]''' from the drop-down. | ||
− | || Click on the drop-down for '''Join | + | || Click on the drop-down for '''Join vector layer'''. |
− | Here we have to select the layer which we want to join with the target layer. | + | Here we have to select the '''layer''' which we want to join with the '''target layer'''. |
Select '''Admin [EPSG: 4326] '''from the drop-down. | Select '''Admin [EPSG: 4326] '''from the drop-down. | ||
Line 489: | Line 474: | ||
|| Cursor on '''Geometry predicate.''' | || Cursor on '''Geometry predicate.''' | ||
− | Click | + | Click on '''within''' option. |
Scroll down and show all the options. | Scroll down and show all the options. | ||
− | || Here we have several options for joining the attributes. | + | || Here we have several options for '''joining''' the '''attributes'''. |
− | + | We are interested to find the meteorological stations located in various states. | |
− | So under '''Geometric predicate''', we will select '''within''' | + | So under '''Geometric predicate''', we will select '''within''' check-box. |
Scroll down. | Scroll down. | ||
Line 517: | Line 502: | ||
|- | |- | ||
− | || Cursor on the ''' | + | || Cursor on the '''Layers panel'''. |
− | ||On the canvas, a new layer, '''Joined layer''' is added in the '''Layers Panel'''. | + | ||On the canvas, a new '''layer''', '''Joined layer''' is added in the '''Layers Panel'''. |
|- | |- | ||
||Open '''attribute table''' of Joined layer | ||Open '''attribute table''' of Joined layer | ||
− | ||Right-click on the '''Joined layer''' and ''' | + | ||Right-click on the '''Joined layer''' and open '''attribute table'''. |
|- | |- | ||
|| Cursor on the '''attribute table'''. | || Cursor on the '''attribute table'''. | ||
− | || This table contains all the attributes | + | || This '''table''' contains all the '''attributes''' from '''Admin layer''' for each point on the '''Stations layer.''' |
Every point feature has information about the state. | Every point feature has information about the state. | ||
|- | |- | ||
− | || Close the attribute table. | + | || Close the '''attribute table'''. |
− | ||Close the attribute table. | + | ||Close the '''attribute table'''. |
|- | |- | ||
Line 541: | Line 526: | ||
Select '''Save As''' option. | Select '''Save As''' option. | ||
|- | |- | ||
− | || In the | + | || In the '''Save As''' dialog-box >> type '''QGIS-Stations''' as file name. |
− | + | ||
− | type '''QGIS-Stations''' as file name. | + | |
Select '''Desktop''' as location. | Select '''Desktop''' as location. | ||
Line 561: | Line 544: | ||
'''Summary''' | '''Summary''' | ||
− | || In this tutorial we have learnt to join the '''attribute tables''' of two | + | || In this tutorial we have learnt to join the '''attribute tables''' of two '''data-sets''' having, |
− | * common field (Table Join), and | + | * common field '''(Table Join)''', and |
− | * same spatial data (Spatial Join) | + | * same '''spatial data (Spatial Join)''' |
|- | |- | ||
Line 571: | Line 554: | ||
|| As an assignment, | || As an assignment, | ||
− | * Join the rainfall data from June to December with the stations | + | * Join the '''rainfall data''' from June to December with the '''stations data'''. |
− | * Use Rainfall.csv and Stations.shp files given in the Code files folder. | + | * Use '''Rainfall.csv''' and '''Stations.shp''' files given in the '''Code files''' folder. |
|- | |- | ||
Line 607: | Line 590: | ||
|| The Spoken Tutorial Project is funded by NMEICT, MHRD Government of India. | || The Spoken Tutorial Project is funded by NMEICT, MHRD Government of India. | ||
− | This tutorial is contributed by Ambadas Maske from College of Engineering Pune | + | This tutorial is contributed by Ambadas Maske from College of Engineering Pune, Snehalatha Kaliappan and Himanshi Karwanje from IIT Bombay. |
− | + | ||
− | Snehalatha Kaliappan and Himanshi Karwanje from IIT Bombay. | + | |
Thank you for joining. | Thank you for joining. | ||
|- | |- | ||
|} | |} |
Latest revision as of 16:13, 28 October 2020
Visual Cue | Narration |
Slide Number 1
Title Slide |
Welcome to this tutorial on Table Joins and Spatial Joins in QGIS. |
Slide Number 2
Learning Objectives |
In this tutorial, we will learn to join the attribute tables of two data-sets having,
|
Slide Number 3
System Requirement |
Here I am using
Ubuntu Linux OS version. 16.04 QGIS version 2.18 |
Slide Number 4
Pre-requisites |
To follow this tutorial learner should be familiar with QGIS interface.
For the prerequisite QGIS tutorials, please visit this website. |
Slide Number 5
Example for Demonstration |
Download the folder given in the Code files link, located below the player.
Extract the contents of the downloaded zip file and save it in a folder. |
Show the map Stations.shp on Desktop. | I have already downloaded the Code files, extracted and saved in a folder on the Desktop. |
Double click on Code files folder.
Point to Stations.shp. |
Double-click on the folder to open it.
Locate Stations.shp file in the extracted folder. |
Point to Stations.shp
Point to other files. |
The Stations.shp file shows locations of meteorological stations or air stations across India.
Here we also have other files required to practice this tutorial. |
Slide Number 6
About Table Joins |
Joining the attribute tables means, combining the attribute data between two data-sets. |
Slide Number 7
About Table Joins https://www.gislounge.com/working-with-tables-mastering-qgis/ |
There are two ways to join a table,
1. Table Join that is, joining tables having one or more common column data. 2. Spatial Join means joining tables having same spatial data. In this tutorial we will be demonstrating both the methods. For more information please visit this website. |
Open QGIS software . | Open QGIS interface. |
Cursor on the interface. | First, we will join attribute tables having common field. |
Click on Add Vector Layer tool. | Click on Add Vector Layer tool from the toolbar on the left-side. |
Add Vector Layer dialog box open.
Click on Browse button. Navigate to Stations.shp file. |
Add Vector Layer dialog box opens.
Click on Browse button next to Dataset field. A dialog-box opens. Navigate to Stations.shp file from the Code files folder on the Desktop. |
Click on Open button. | Click on Open button. |
Add vector Layer dialog box will open.
Click on Open. |
In the Add vector layer dialog box, click on Open button. |
Cursor on Layers panel.
Cursor on the map. |
The Stations.shp layer will be added in the Layers Panel.
The corresponding map appears on the canvas. |
Right-click on Stations.shp layer in the Layers panel. | This map shows point features, corresponding to meteorological stations located in different states in India.
Let us open the attribute table for this layer. In the Layers Panel, right-click on Stations.shp. |
Click on Open Attribute Table option. | From the context menu choose Open Attribute Table option. |
Cursor on the Attribute table window. | Attribute table opens.
Notice that data for only one attribute District is available. |
Click on the minimize button on the top-left corner of the Stations table. | Minimize the attribute table. |
Click on Layers menu from the menu bar. | Now we will add another data-set which is a spreadsheet to the Layers Panel.
This data set is in CSV format. |
Click on Layer menu.
From the drop-down menu select Add Layer option. From the sub-menu click on Add Delimited Text Layer option. |
Click on Layer menu on the menu bar.
Click on Add layer. From the sub-menu click on Add Delimited Text Layer option. |
Create a layer from Delimited Text File dialog box open.
Click on Browse Button. |
A dialog box opens.
Click on Browse button located next to File Name field. |
Navigate to Rainfall.csv file.
Click on Open Button. |
A dialog box opens.
Navigate to Rainfall.csv file from the Code files folder on the Desktop. Click on Open button. |
Cursor on Delimited Text File dialog box.
Select CSV as File Format. |
In the Delimited Text File dialog box, select CSV as File Format. |
Click on the No geometry (attribute only table). | Select Geometry definition as No geometry.
Leave all other fields as such. |
Click on OK button. | Click on OK button. |
Cursor on Layers panel. | On QGIS canvas, Rainfall layer will be added in the Layers Panel. |
Cursor on Rainfall.csv Layer.
Click on the Open Attribute Table from context menu. |
Right-click on Rainfall layer.
Click on the Open Attribute Table from the context menu. |
Point towards the attribute table columns. | Attribute table opens.
The attribute table has rainfall data from January to December for various districts. |
Cursor on the tables. | Maximize the Stations attribute table and compare both the tables. |
Point to District field in both the tables. | Please note, the District field is common in both Rainfall and Stations layers. |
Add attribute data.
Cursor on the station layer. |
Now we will add the attribute data from Rainfall layer to Stations layer. |
Cursor on the first column of the Attribute table . | In the Stations attribute table there is only one column named District.
We will add the Rainfall data to the Stations attribute table. |
Click on x button on the top-left corner of the table. | Close the attribute tables. |
Click on Stations layer in Layer’s panel.
Cursor on Stations layer. |
Select Stations layer in the Layers Panel.
This layer will receive the new data from the Rainfall layer. |
Right click on the stations layer.
Click on the Properties option from context menu. |
Right-click on Stations layer.
Click on the Properties option from the context menu. |
Layer Properties dialog box will open.
Click on Joins from the left panel. |
Layer Properties dialog box opens.
Click on Joins from the left panel. |
Cursor on the Joins window.
Click on Plus sign. Add vector Join dialog-box opens. |
In the new window, click on the plus sign, located on the bottom-left corner.
Add vector join dialog box opens. |
Cursor on the options. | Here we have options to choose for Join layer, Join field and Target field. |
Cursor on Join layer field. | Join layer will be Rainfall layer, from which data will be added to Stations attribute table.
Here Rainfall layer is already selected. |
Click on the Join field.
Cursor on the Join field. Select Districts. |
Join field is the field or attribute in the Rainfall table to be joined.
In the Join field, select District from the drop-down. |
Point to the Target field.
Cursor on the District. |
Target field is the field to be joined in the Stations table.
In the Target field, District is already selected. This field is common to both the tables. |
Cursor on Choose which fields are Joined.
Scroll down the slider to see all the check-boxes. |
Check the check-box for Choose which fields are joined.
The text-box below is now populated with all the columns and check-boxes. |
Check all the check-boxes from January to Annual Average.
Click on OK button. |
Check the boxes for the columns January to Annual Average in the text box.
Click on OK button to close the Add vector join dialog box. |
Dialog box will open.
Click on Apply button >>OK. |
In Layer Properties dialog box, information about layer and columns joined are indicated at the top.
Click on Apply button, then OK button. |
Cursor on QGIS Interface.
Cursor on the Layers Panels. Right Click on Stations layer. |
On the QGIS interface, as shown earlier open attribute table for Stations layer. |
Select Open attribute table. | Observe that this table shows Rainfall data for all the stations. |
Click on x button on top-left corner of Stations layer. | Close attribute table. |
Add another data set.
Point to the Layers panel. |
Next, we will learn how to join attribute table of two data-sets by location.
Let us add another layer to the Layers Panel. |
Select Add Vector Layer tool from the left tool-bar. | For this click on Add Vector Layer tool. |
Click on the Browse button next to the Dataset.
Navigate to the Admin.shp |
In the Add Vector Layer dialog box, click on Browse button.
Navigate to the Admin.shp from the Code files folder on the Desktop. |
Click on Open button. | Click on Open button. |
Click on Open button in Add Vector Layer dialog box.
Point to the Admin layer in the Layers panel. |
Again click on Open button in the Add Vector Layer dialog box.
Admin layer is now added to the Layers Panel. |
Cursor on the map. | Admin layer map opens showing the administrative state boundaries of India. |
Click the Admin layer in the Layers panel.
Drag and bring it below station layer. Cursor on the map. |
Click the Admin layer in the Layers panel.
Drag and bring it below Stations layer. Now we can view the point features located in different States. |
Right click on the Admin layer.
Select Open attribute table. |
Open attribute table for Admin layer. |
Cursor on the attribute table.
Minimize the Admin attribute table. Open Stations attribute table. |
The attribute table shows information related to states.
Minimize the Admin attribute table. Again open the Stations attribute table. Now we will join the attributes by location for Stations layer and Admin layer. |
Cursor on map. | Close both the attribute tables. |
Click on Vector >>Data Management Tools>>Join attributes by location. | Click on Vector menu.
Scroll down the menu and click on Data Management Tools. From the sub-menu select Join attributes by location. |
Cursor on Join attribute by location. | Join attributes by location dialog box opens. |
Cursor on Target vector layer. | Click on the drop-down for Target vector layer. |
Cursor on the Stations layer.
Select Stations[EPSG: 4326]. |
Here we need to specify the target vector layer for joining the attribute table.
In our case we need to add new data to the Stations layer. Hence Stations layer is the Target Layer. So we will select Stations [EPSG: 4326] from the drop-down as target layer. |
Cursor on join Vector Layer.
Select Admin [EPSG: 4326] from the drop-down. |
Click on the drop-down for Join vector layer.
Here we have to select the layer which we want to join with the target layer. Select Admin [EPSG: 4326] from the drop-down. |
Cursor on Geometry predicate.
Click on within option. Scroll down and show all the options. |
Here we have several options for joining the attributes.
We are interested to find the meteorological stations located in various states. So under Geometric predicate, we will select within check-box. Scroll down. |
Check the check-box for Open output file after running algorithm. | Check the check-box for Open output file after running algorithm. |
Click on the Run button. | Leave the rest of the settings as default.
Click on the Run button. |
Point to status bar. | Status bar at the bottom shows the progress of the processing algorithm.
Wait for the process to complete. |
Cursor on the Layers panel. | On the canvas, a new layer, Joined layer is added in the Layers Panel. |
Open attribute table of Joined layer | Right-click on the Joined layer and open attribute table. |
Cursor on the attribute table. | This table contains all the attributes from Admin layer for each point on the Stations layer.
Every point feature has information about the state. |
Close the attribute table. | Close the attribute table. |
Click on the Project menu from the menu bar>> select Save As >> type appropriate name. | To save the project, click on Project menu from the menu bar.
Select Save As option. |
In the Save As dialog-box >> type QGIS-Stations as file name.
Select Desktop as location. |
Give an appropriate name and select a convenient location. |
Click on Save button. | Click on Save button. |
Let us summarize. | |
Slide Number 8
Summary |
In this tutorial we have learnt to join the attribute tables of two data-sets having,
|
Slide Number 9
Assignment |
As an assignment,
|
Show the glimpse of completed assignment. | The completed assignment should look like this. |
Slide Number 10
About the Spoken Tutorial Project |
This video summarizes the Spoken Tutorial project.
Please download and watch it. |
Slide Number 11
Spoken Tutorial Workshops |
The spoken tutorial project team conducts workshops and gives certificates.
For more information please write to us. |
Slide Number 12
Forum for specific question |
Please post your timed queries on this forum. |
Slide Number 13
Acknowledgement |
The Spoken Tutorial Project is funded by NMEICT, MHRD Government of India.
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
Karwanjehimanshi95, Madhurig, Nancyvarkey, PoojaMoolya, Snehalathak