QGIS/C4/Nearest-Neighbour-Analysis/English-timed
From Script | Spoken-Tutorial
Revision as of 10:56, 21 December 2020 by PoojaMoolya (Talk | contribs)
Time | Narration |
00:01 | Welcome to this tutorial on Nearest Neighbour Analysis in QGIS. |
00:07 | In this tutorial, we will learn about |
00:11 | Nearest Neighbour Analysis by Distance matrix method. |
00:16 | Statistics using Nearest Neighbour Analysis tool. |
00:21 | Here I am using,
Ubuntu Linux OS version. 16.04 QGIS version 2.18 |
00:32 | To follow this tutorial learner must be familiar with QGIS interface. |
00:39 | For pre-requisite QGIS tutorials, please use this link. |
00:45 | The files required to practise this tutorial are available in the Code files link. |
00:52 | Please download and extract the contents of the folder. |
00:57 | Here I have the folder with the required file to practise this tutorial. |
01:04 | Double-click to open the folder.
Here you will find, Urban areas.shp and Volcanoes.shp. |
01:15 | Volcanoes.shp layer shows active volcanoes in the world. |
01:21 | Urban areas.shp shows populated urban areas of the world. |
01:28 | Open the two shape files in QGIS, select both the files. |
01:35 | Right-click and select Open with QGIS Desktop option from the context menu. |
01:42 | QGIS interface opens with two layers loaded in the layers panel. |
01:49 | Right-click on the volcanoes layer and select zoom to layer option. |
01:55 | On the canvas you will see a map with point features. |
02:01 | Let us label these point features. |
02:05 | Right-click on Volcanoes layer, from the sub menu click on Properties. |
02:12 | Layer Properties dialog-box opens. |
02:16 | Select Labels from the left panel. |
02:20 | Select Show labels for this layer option from the drop down. |
02:25 | In the Label with drop down select Name. |
02:29 | Here you will find various options to modify the label style. |
02:34 | Choose the required style and click on OK button. |
02:39 | On the canvas, points with the names is displayed. |
02:44 | Similarly let us label Urban areas. |
02:51 | On the canvas point features are labeled with their cities. |
02:57 | QGIS has tools to analyze spatial relationships between features. |
03:04 | One such tool is Nearest Neighbour Analysis. |
03:08 | Nearest Neighbour Analysis is used for the following analysis. |
03:13 | Finding distance between two Point features. |
03:17 | Finding features which are closest to a given feature. |
03:23 | First, we will create distance matrix for calculating the distances. |
03:29 | Let us open the attribute table for the Volcanoes layer. |
03:34 | Right-click on Volcanoes layer. |
03:37 | Select Open Attribute Table. |
03:40 | In the attribute table there are multiple columns. |
03:45 | Various attributes for the point features are listed here. |
03:50 | Names of the volcanoes and their locations are also listed here. |
03:56 | Close the attribute table. |
03:59 | Open the attribute table for the Urban areas layer. |
04:04 | Notice the various columns in the table. |
04:08 | You will find names of the cities, countries and other information in this table. |
04:15 | Close the attribute table. |
04:18 | Let us calculate the distance between the active volcanoes and nearest cities. |
04:24 | Click on Vector menu. |
04:27 | Select Analysis Tools. |
04:30 | Select Distance Matrix option from the sub-menu. |
04:34 | Distance Matrix dialog-box opens. |
04:38 | Please read the description about Distance matrix on the right-panel. |
04:44 | By default Parameters tab opens on the screen. |
04:49 | Select the Parameters as shown here. |
04:53 | Select Volcanoes as an Input Point Layer. |
04:58 | Select NAME as Input unique ID field |
05:03 | Select Urban Areas as Target Point Layer. |
05:08 | Select City as Target unique ID field. |
05:13 | Keep Output matrix type as Linear. |
05:17 | Let us find the distance from the volcano to two nearest cities. |
05:23 | Hence, select 2 in Use only the nearest target Points field. |
05:30 | Click on the 3 dots button next to Distance Matrix field. |
05:35 | From the drop-down menu, select Save to file. option. |
05:40 | In the dialog-box, give an appropriate name and location. |
05:44 | Choose Files of type, as CSV . |
05:49 | In the Encoding field choose System.
Click on Save button. |
05:56 | In the Distance matrix dialog-box check the check-box for the following.
Open output file after running algorithm. |
06:06 | Click on the Run button at the bottom-right corner of the dialog box. |
06:12 | The process will take few seconds. |
06:15 | A new csv layer named as Distance matrix is added in the Layers panel. |
06:22 | Open the attribute table for Distance matrix layer. |
06:27 | In the attribute table there are three columns.
The last column is the distance between the volcano and nearest city. |
06:38 | Please note, here the distance is in meters. |
06:43 | This is because the layers are projected in WGS 84 UTM Zone 46N system. |
06:52 | Depending on the CRS, the distance can also be in layer units or in degrees. |
07:00 | Also observe that for each volcano, two nearest cities are listed. |
07:07 | Let us get some statistical analysis for the layers using Nearest neighbour tool. |
07:14 | We will run a nearest neighbour analysis to analyze the distribution of features. |
07:21 | The results will establish, the distribution as clustered, dispersed or random. |
07:29 | Close the attribute table. |
07:32 | Click on Vector menu. |
07:35 | Scroll down and click on the Analysis Tools. |
07:40 | From the sub-menu, select the Nearest Neighbour analysis. |
07:46 | Nearest Neighbour Analysis dialog-box opens. |
07:50 | Read the information given about Nearest neighbour analysis on the right-panel. |
07:57 | Select Volcanoes layer in the Points drop-down. |
08:02 | Click on Run button at the bottom-right corner. |
08:06 | Results window opens. |
08:09 | Some statistical parameters for the volcanoes layer are listed here. |
08:15 | Observed mean distance |
08:17 | Expected mean distance |
08:20 | Nearest neighbour index |
08:23 | Number of point features and
Z-Score. |
08:29 | The Nearest Neighbour Index is expressed as the ratio of the Observed Mean Distance to the Expected Mean Distance. |
08:39 | If the index value is less than 1, the pattern exhibits clustering. |
08:45 | If the index value is greater than 1, the trend is towards dispersion. |
08:52 | Here the Nearest Neighbor Index value of 0.2 indicates clustering.
Which means, the volcanoes are located close to each other. |
09:04 | Similarly a negative Z-Score also indicates clustering of point features. |
09:10 | Close the Results window. |
09:13 | Save the project using Project menu. |
09:17 | Let us summarize. |
09:19 | In this tutorial we have learnt about, |
09:22 | Nearest Neighbour Analysis by Distance Matrix method.
Statistics using Nearest Neighbour Analysis tool. |
09:32 | As an assignment, Create Distance Matrix for nearest 5 volcanoes to urban areas.
Hint: Use Urban Areas as Input and K as 5. |
09:46 | Your completed assignment should look as shown here. |
09:51 | The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it. |
09:59 | The Spoken Tutorial project team conducts workshops and gives certificates. For more details please write to us. |
10:09 | Please post your timed queries in this forum. |
10:13 | The Spoken Tutorial Project is funded by, MHRD Government of India. |
10:20 | This tutorial is contributed by Ambadas Maske from College of Engineering Pune, Snehalatha Kaliappan and Himanshi Karwanje from IIT Bombay.
Thank you for joining. |