QGIS/C2/Raster-Data-Styling/English

From Script | Spoken-Tutorial
Revision as of 13:29, 5 April 2019 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 Raster Data Styling in QGIS.
Slide Number 2

Learning Objectives

In this tutorial, we will learn,
  • to style a continuous raster.
  • to write an expression in Raster Calculator.
  • About raster properties.
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


https://spoken-tutorial.org

To follow this tutorial you should be familiar with QGIS interface.


For the prerequisite tutorials please visit our 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.

Point to Code-file folder on desktop.

Double-click on Code-file folder.

Here is my Code files folder.


Double-click to open the folder.

Point to glds00ag60.asc and glds90ag60.asc files.


In this folder you will find Population Density grid files for the entire world, for the year 2000 and 1990.


There are two files in ASCII format, with .asc file extension.


Let us open these files in QGIS.


Close the Code files folder.

Open QGIS interface.


Click on Layer menu, from the drop-down menu select Add Raster Layer.

Here I have opened QGIS interface.


Click on Layer menu.


From the drop-down select Add Layer.


From the sub-menu, select Add Raster Layer.

Point to Raster Data Source dialog-box.


Press and hold the ctrl key, click on both the files.


pop-1990 and pop-2000.

A dialog-box opens. I will navigate to the Code file folder on the Desktop.


Select the two files with .asc file extension.


Press and hold the Ctrl key, click on both the files.

Click on Open button. Click on Open button.
Cursor on Coordinate Reference System Selector.


Coordinate Reference System Selector opens.


In some settings, CRS will be selected automatically.


In such a situation this window may not open.


If Coordinate Reference System Selector does not open, ignore this step and proceed with the next step.

Select WGS 84 EPSG:4326 from the list.

Click on OK button.

Here I will select WGS 84 EPSG 4326 from the list.


Click on OK button.

Cursor on Coordinate Reference System Selector. Since we are adding two layers at the same time, Coordinate Reference System Selector opens once more here.
Select WGS 84 EPSG:4326 from the list.

Click on OK button.

Again select WGS 84 EPSG 4326.


Click on OK button.

Cursor on world map. On the canvas you will see a world map rendered in grayscale.

Lighter pixels indicate higher population and darker pixels indicate lower population.

Cursor on Layers panel. In the Layers Panel, you will see both the raster layers loaded.
Cursor on map.

(Zoom-in the map)

Each pixel in the raster has a value of population density for that grid.
Click on Identify Features tool on the tool bar. (blue square icon with small i) To see the value of the pixel, click on Identify Features tool on the top-right corner of the toolbar.
Click on a pixel on map.

Point to the value.

Use the mouse wheel to zoom in the map.

Click anywhere on the raster map.

The pixel value will be displayed in the Identify Results panel.

Click on darker pixel.


Click on lighter pixel.

Observe that the lighter pixel has higher value and the darker pixel has lower value.


Close the Identify Results panel.

Cursor on canvas. Zoom out the map.

Click on Pan Map tool and adjust the map on the canvas.

Population density pattern can be better visualized with an appropriate type of styling.
Right-click on the 1st layer in the Layers Panel.


Select Properties option.

Right-click on the 1st layer in the Layers Panel.


From the context menu select Properties option.

Cursor on Layer Properties dialog-box. Layer Properties dialog-box opens.
Style>>Render type>> Singleband pseudocolor In the dialog-box select Style tab.


Under Band Rendering section, change the Render type to Singleband pseudocolor.

Under Load min/max values, click on Colors text box drop-down.

Choose Spectral.

Let the Interpolation be Linear.

In the Color drop-down, select Spectral.

(Maximise the properties dialog-box).

Cursor on Value column.

Scroll down.

Select Mode as Continuous.


Click on Classify button.

Cursor on the middle panel. You will see 5 new color values created.
Click on OK button. Click on Apply button and OK button at the bottom right corner of the dialog-box.
Cursor on QGIS Canvas. Back in the QGIS Canvas, you will see the raster map displayed in 5 classes of spectral color rendering.
Properties>>Style>>Render type>> Singleband pseudocolor>> Classify Follow the same steps as shown for 1st layer and change the raster style for 2nd layer.
Cursor on the canvas. For our analysis, we would like to find areas with largest population change between years 1990 and 2000.
Cursor on panel. For this, we need to find the difference between each grid’s pixel values in both the layers.

For these calculations, we will use Raster Calculator tool.

Click on Raster menu from the menu bar.

From the drop-down, click on Raster calculator.

Click on Raster menu from the menu bar.

From the drop-down, click on Raster calculator.

Raster Calculator dialog-box opens. Raster Calculator dialog-box opens.
Cursor on Raster bands section. In the Raster bands section, the names of the bands are displayed.

Since each of our rasters have only 1 band, you will see only 1 entry per raster.

Cursor on Raster bands section. The raster calculator can apply mathematical operations on the raster pixels.
Cursor on Raster bands section. In this case we want to enter a simple formula
  • to subtract the population density for the year 1990
  • from the population density for the year 2000.
Double-click on the raster layer for the year 2000 (pop-2000@1). Under Raster bands section, select the layer by double-clicking on the raster layer for the year 2000.
Point to Raster calculator expression section. The expression is now added to the Raster calculator expression section.
From the Operators section, click on subtraction operator.


From the Raster bands section, double-click on raster layer for the year 1990 (pop-1990@1).

From the Operators section, click on subtraction operator button.


Again from the Raster bands section, double-click on raster layer for the year 1990.

Cursor on formula.

pop-2000@1 - pop-1990@1

The formula for the calculation is now displayed in the Raster calculator expression section.
Result Layer section, in the Output layer box,


In the output layer field, type, pop-density-change.tif.

Under Result Layer section, you will see Output layer box.


In the box, type the name of your output layer as pop-change.tif.

Output format as Geo TIFF. In the Output format drop-down, select Geo TIFF.
Cursor on Output CRS option. Output CRS option is automatically selected. Leave it as such.
Check the box next to Add result to project. Check the box next to Add result to project.
Click on OK button. Click on OK button at the bottom of the dialog-box.
Cursor on Layers Panel. You will see the new layer load in Layers Panel.
In the Layers Panel, uncheck the check boxes for pop-2000 and pop-1990 layers. To view the map for the 3rd layer,

in the Layers Panel uncheck the check boxes for pop-2000 and pop-1990 layers.

Cursor on canvas. We can create a much more informative map by changing the style of this layer.
Right-click on the pop-density-change layer.


From the context menu select Properties option.

Right-click on the pop-change layer.


From the context menu, select Properties option.

Cursor on Layer Properties dialog-box. Layer Properties dialog-box opens.
Cursor on the canvas. We want to style the layer such that, pixel values in certain ranges get the same color.
Click on Metadata tab

Scroll down and point towards minimum and maximum values.

STATISTICS_MAXIMUM=5775.919921875

STATISTICS_MINIMUM=-1840.7290039062

Click on Metadata tab, scroll down to Properties section.


Note the maximum and minimum values.


Maximum value is close to 6000.


Minimum value is just above -2000.

Click on Style tab.


Band Rendering >>Render type select Singleband pseudocolor.

Go to the Style tab.


Under Band Rendering, select Singleband pseudocolor as the Render type.

interpolation>> Discrete Set the Interpolation to Discrete.
Click the Add Values Manually (green plus symbol button located next to Classify button) button 4 times.


Cursor on the values.

Scroll down.


Locate Add Values Manually button.


This is a green plus symbol button located next to Classify button.


Click the Add Values Manually button 4 times to create 4 unique classes.


These values show-up in the middle panel.

Cursor on the values. Here we have to change the values in each row.


Population values lower than the value entered, will be given the color of that entry.

Double click on value in the Value column. Double-click on the first entry in the Values column to change the value.
Type -2000.


We have observed, the minimum value in our metadata analysis is just above -2000.


Type -2000 in the first entry.

Double-click on the color-box and change the color. Red color Double-click on the color-box and change the color.
Double-click on the Label column in the first row.

Type, No Data values.

Double-click on the Label column in the first row.

Type, No Data values.

Point to the table. Similarly fill in all the values and labels as shown here.
Point to the table.

Light Green

In the 2nd row, -10 to denote Negative change.
Point to the table.

Pink

In the 3rd row, 10 to denote Neutral.
Point to the table.

Blue

Finally 6000 to denote Positive change.


Because our maximum value from the meta data analysis is close to 6000.

Click on OK button. At the bottom-right corner of the window, click on Apply button and then OK button.
Point to the map on the canvas. Now on the canvas you will see a much more powerful visualization of the population data.


Here you can see clearly areas which has seen positive and negative population density changes.

Point to the map on the canvas. Areas colored in blue denote the positive population change.

Areas in green show negative change.

Areas in pink have not see too much population change.

Slide Number 6

Summary

Let us summarize,

In this tutorial we have learnt,

  • to style a continuous raster.
  • to write an expression in raster calculator.
  • About raster properties.
Slide Number 7

Assignment

As an assignment
  • Using the population data given in the Code files link,
  • Create a new raster file which shows only negative population change.
  • Hint: Use Raster Calculator, write an expression to select population change less than 0.
Show images of assignment. Your completed assignment should look as shown here.
Slide Number 8

About 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 This tutorial is contributed by Prajwal.M from NIT Surathkal and Snehalatha from IIT Bombay.

Thank you for watching.

Contributors and Content Editors

Nancyvarkey, Snehalathak