QGIS/C2/Geometric-Properties-of-Vectors/English

From Script | Spoken-Tutorial
Revision as of 15:39, 14 December 2018 by Snehalathak (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Visual Cue Narration
Slide Number 1

Title Slide

Welcome to this tutorial on Geometric Properties of Vectors.
Slide Number 2

Learning Objectives

In this tutorial, we will learn to
  • Show selected features from the attribute table on the map.
  • Add columns to the attribute table.
  • Calculate statistics for the attributes.


Slide Number 3

System Requirement

To record this tutorial, I am using,


Ubuntu Linux OS version 16.04

QGIS version 2.18

Slide Number 4

Pre-requisites

To follow this tutorial you should be familiar with,

QGIS interface.


If not for relevant tutorials please visit our website.

Slide Number 5

Example map to practise


To practise this tutorial,


you need to download the folder given in the Code files link located below the player.


Extract the contents of the downloaded zip file.


Locate IND_rails.shp file in the extracted folder.

Show the map on desktop. I have already downloaded the code file, extracted and saved in a folder on desktop.
Double-click on Code-files.


Right-click on IND_rails.shp file.


From the context menu select Open with, QGIS Desktop.

Double-click on Code-file folder on the desktop to open it.


Right-click on IND_rails.shp file.


From the context menu select, Open with QGIS Desktop.

Cursor on the map.


QGIS interface opens.


Click on OK button to close the QGIS tips dialog-box.

Cursor on the map.


Map of India with lines representing railroads opens on canvas.
Cursor on the map. We will calculate line lengths for rail roads which are operational.


To view this information we need to open the attribute table.

Right-click on IND_rails layer in the Layers Panel. Right-click on IND_rails layer in the Layers Panel.
From the context menu select Open Attribute Table option. From the context menu select Open Attribute Table option.
Cursor on attribute table. Attribute table opens.
Point to EXS_DESCRI column.


The table has an attribute called EXS_DESCRI.


We can use the value of this attribute to select features which are operational.

Cursor on EXS_DESCRI column. This column shows the status of a particular railway line.


These are categorized as Operational, Unexamined or Unsurveyed and not Usable.

Cursor on EXS_DESCRI column. We need to select the lines which are operational.
Click Select features using an expression tool in the attribute table tool bar.

(It will be seen in yellow color)

In the attribute table window,


Click Select features using an expression tool in the tool bar.

Cursor on Select By Expression dialog-box. A new dialog-box Select By Expression opens.
Click on black triangle next to Fields and Values option.


In the Function Editor panel,click on the black triangle next to Fields and Values option.
Double click on EXS_DESCRI.


Cursor on Expression text area.

From the list select EXS_DESCRI attribute.Double-click on it and add it to the Expression text area.
Type the expression

= 'Operational'.

Click Select button.

Click Close button.

Complete the expression by typing


"EXS_DESCRI" equal to, in single quotes Operational

Cursor on the expression. Please note, the syntax here is case sensitive.

Type the words as they appear in the attribute table.

Here “O” in Operational is Capital letter.

Click on Select button followed by Close button at the bottom of the table. At the bottom of the table, click on Select button followed by Close button.
Point to the selected category.


Close the attribute table.

The Operational category are selected in the attribute table.


Close the attribute table.

Cursor on QGIS window.


On the map, you will see that all lines that fall in Operational category are selected.


These lines appear in yellow.

Right click on IND_rails from the context menu, select Save Selection As.... option. Now let’s save our selection to a new shapefile.


Right-click on IND_rail layer and select Save As....option.

Cursor on Save Vector Layer as ….. dialog-box. Save Vector Layer as ….. dialog-box opens.
Click on Browse button. Click on Browse button, next to File name field.
In Save Layer As... dialog-box.

Type railway.shp in the name field.

Save Layer As... dialog-box opens.


Name the output file as railway.shp.

Select Desktop.


Click on Save button.

Select a location, I will choose Desktop.


Click on Save button.

Now let us select CRS for this layer.


Click on Select CRS button.

Cursor on Coordinate Reference System Selector. Coordinate Reference System Selector dialog-box opens.
Type Indian 1975 in the Filter search box. Since we are interested in calculating length, let us select an equidistance projection.


Type Indian 1975 in the Filter search box.

Select Indian 1975 EPSG:4240. Under Coordinate Reference Systems of the world,


in Geographic Coordinate Systems section.

select Indian 1975 EPSG:4240.

Click on OK button. Click on OK button.
Cursor on Save vector layer as... dialog-box. In the Save vector layer as... dialog-box,


by default, Add saved file to map is already checked.

Tick Save only selected features box. Check Save only selected features check box.
Click on OK button. Click on OK button.
Cursor on railway layer in Layers Panel. Once the export process finishes, you will see a

new layer railway loaded in Layers Panel.

Uncheck the box next to IND_rail layer. In the Layers Panel,


you can uncheck the box next to IND_rail layer,


to turn it off as we don’t need it any more.

Cursor on the canvas. On the canvas you will see the map of India with only operational railway lines.
Right-click on the railway layer and select Open Attribute Table. Right-click on the railway layer and select Open Attribute Table.
Cursor on attribute table. Now we will add a column with length of each feature.
Click Toggle editing button on the tool bar. Put the layer in editing mode by clicking on the Toggle editing tool on the tool bar.
Click on Open field calculator icon on the right-hand corner of the tool bar. Then click the Open field calculator button,

available on the right-hand corner of the tool bar.

In the Field Calculator dialog-box, check Create a new field option. In the Field Calculator dialog-box, check Create a new field check box.



In the Output field name text box, type length-km. Type length-km in the Output field name text box.
Choose Decimal number (real) as the Output field type. Choose Decimal number (real) as the Output field type.
Increase the precision to 2. Change the output Precision to 2.
Click the triangle next to Geometry, select $length.


In the Function editor panel,


Click the triangle next to Geometry and select $length.

Double click on $length. Double-click on $length to add it to the Expression text box.
Type, $length / 1000


Click on Division Operator button on top of the text window.


Type 1000

Complete the expression as $length divided by 1000.


Click on Division Operator button on top of the text window.


Type 1000 on the keyboard.

Click on OK button. We need to divide the output length by 1000,


because railway layer CRS is in meters unit and we want the output in kilo meters.


Click on OK button.

Click on Toggle editing tool. Click on Toggle editing tool to stop editing.
In the Stop editing dialog-box,


click on save button,

In the Stop editing dialog-box,


click on save button, to save the changes to the attribute table.

Cursor on Attribute table.

Point to Length_km.

Back in attribute table, a new column Length_km has been added.
Cursor on Length_km column. Now we have length of each individual line in Railway layer.


We can add it all up and find the total length.

Cursor on Attribute table. Close the attribute table.
Click on Vector menu on the menu bar.

Select Analysis Tools option.


From the sub-menu, click on Basic Statistics for numeric tools option.

Click on Vector menu on the menu bar.


Select Analysis Tools option.


From the sub-menu, click on Basic Statistics for numeric tools.



Basic Statistics for numeric tools dialog-box opens. A dialog-box opens.
Click on Input vector layer, choose railway.


Click on Field to calculate statistics on, choose length_km.

Select Input vector layer as railway.


Choose Field to calculate statistics on as length_km.

Click on Run button. Click on Run button at the bottom right corner of the dialog-box.
Point to Sum value. Results window opens.


Here you will see various statistics results.


The Sum value shown here is the total length of the railroads.

Cursor on the Results window. Note, The answer may vary slightly if a different projection is chosen.
Cursor on the Results window. In practice, line lengths for roads and other linear features are measured on the ground.


These values are provided as attributes to the dataset.

Cursor on the Results window. The method demonstrated above works in the absence of such attribute,


and as an approximation of actual line lengths.

Slide Number 6

Summary

Let us summarize,

In this tutorial we have learnt to,

  • Show selected features from the attribute table on the map.
  • Add columns to the attribute table.
  • Calculate statistics for the attributes.
Slide Number 7

Assignment

Assignment
  • Use the code file world_1.shp, downloaded from the Code files link.
  • Find the area in square-kilometers for different countries.


Cursor on the asignment. Your completed assignment should look as shown here.
Slide Number 8

About the Spoken Tutorial Project

The video at the following link summarises the spoken tutorial project.
  • Please download and watch it.


Slide Number 9

Spoken Tutorial Workshops

* The spoken tutorial project team conducts workshops and gives certificates on passing online tests
  • For more details please write to us.


Slide number 10

Forum for specific questions:

Please post your timed queries on this forum.
Slide number 11

Acknowledgements

The Spoken Tutorial Project is funded by NMEICT, MHRD Government of India.


More information on this mission is available at the following link.

Slide number 11

Acknowledgements

This tutorial is contributed by Prajwal.M from NIT Surathkal and Snehalatha from IIT Bombay.


Thank you for joining.

Contributors and Content Editors

Nancyvarkey, Snehalathak