TUTORIAL NO.
03
NAME OF TUTORIAL: VECTOR DATA
A. Working with Vector Data
1. Open the exercise_data/shapefile/protected_areas.shp file according to the steps
given in Experiment No. 1 → E. Basics: Prepare A Map (Tutorial).
(The polygons representing the protected areas constitute the spatial data, but we can
learn more about the protected areas by exploring the attribute table)
2. In the Layers panel, click on the protected_areas layer to select it.
Open Attribute Table
3. In the Layer menu, click the button (also accessible from top
toolbars buttons). This will open a new window showing the attribute table of
the protected_areas layer.
A row is called a record and is associated with a feature in the Canvas Map, such as a
polygon. A column is called a field (or an attribute), and has a name that helps describe it,
such as name or id .
Next, let’s see how a record in the attribute table is linked to a polygon feature that we see on
the Map Canvas.
1. Go back to the main QGIS window.
2. In the Edit ► Select menu, click on the Select Feature(s) button.
18
3. Make sure the protected_areas layer is still selected in the Layers panel.
4. Move your mouse to the Map Canvas and left click on the smaller of the two
polygons. The polygon will turn yellow indicating it is selected.
5. Go back to the Attribute Table window, and you should see a record (row)
highlighted. These are the attribute values of the selected polygon.
B. Using Labels
1. Similar to how the exercise_data/shapefile/protected_areas.shp file was uploaded
from exercise data, also upload roads , rivers , water , landuse and places shapefiles.
First, ensure that the button is visible in the GUI:
2. Go to the menu item View ► Toolbars
3. Ensure that the Label Toolbar item has a check mark next to it. If it doesn’t, click on
the Label Toolbar item to activate it.
4. Click on the places layer in the Layers panel so that it is highlighted
5. Click on the toolbar button to open the Labels tab of the Layer Styling panel
6. Switch from No Labels to Single Labels
19
7. Select name from the Value list:
8. Click Apply
20
9. Similarly you can apply labels to roads , rivers , water etc,.
10. You’ll see that some of the road or river names appear more than once and that’s not
always necessary. To prevent this from happening, in the Labels tab of the Layer
Properties dialog, choose the Rendering option and select Merge connected lines
to avoid duplicate labels .
C. Data Defined Settings
1. Deactivate labeling for the roads layer
2. Reactivate labeling for the places layer
3. Open the attribute table for places via the button
It has one field which is of interest to us now: place which defines the type of urban area for
each record. We can use this data to influence the label styles.
21
4. Navigate to the Text panel in the places Labels panel
5. Click the button next to the Italic text button beneath Style and select Edit… to
open the Expression String Builder :
6. Under Fields and Values , double click on place and then click All Unique . This
will list all unique values of the place field of this layer. Add a = in the text editor
and then double click on town .
Alternatively, you can type: "place" = 'town' directly in the text editor.
7. Click OK twice:
22
Notice that the labels for all places whose place field matches town are displayed in italics.
23
D. Classifying Nominal Data
Labels are a good way to communicate information such as the names of individual places,
but they can’t be used for everything. For example, let us say that someone wants to know
what each landuse area is used for.
In that case, following are the steps on how to classify vector data effectively:
1. Open the Layer Properties dialog for the landuse layer
2. Go to the Symbology tab
3. Click on the dropdown that says Single Symbol and change it to Categorized :
4. In the new panel, change the Value to landuse and the Color
ramp to Random colors
5. Click the button labeled Classify
24
6. Click OK
25
E. Types of Classification
here are four types of classification: nominal, ordinal, interval and ratio.
In nominal classification, the categories that objects are classified into are name-based; they
have no order. For example: town names, district codes, etc. Symbols that are used for nominal
data should not imply any order or magnitude.
• For points, we can use symbols of different shape.
• For polygons, we can use different types of hatching or different colours (avoid mixing
light and dark colours).
• For lines, we can use different dash patterns, different colours (avoid mixing light and
dark colours) and different symbols along the lines.
In ordinal classification, the categories are arranged in a certain order. For example, world
cities are given a rank depending on their importance for world trade, travel, culture, etc.
Symbols that are used for ordinal data should imply order, but not magnitude.
• For points, we can use symbols with light to dark colours.
• For polygons, we can use graduated colours (light to dark).
• For lines, we can use graduated colours (light to dark).
In interval classification, the numbers are on a scale with positive, negative and zero values.
For example: height above/below sea level, temperature in degrees Celsius.
• For points, we can use symbols with varying size (small to big).
• For polygons, we can use graduated colours (light to dark) or add diagrams of varying
size.
• For lines, we can use thickness (thin to thick).
In ratio classification, the numbers are on a scale with only positive and zero values. For
example: temperature above absolute zero (0 degrees Kelvin), distance from a point, the
average amount of traffic on a given street per month, etc.
• For points, we can use symbols with varying size (small to big).
• For polygons, we can use graduated colours (light to dark) or add diagrams of varying
size.
• For lines, we can use thickness (thin to thick).
• ---X---End---X---
26