GIS AH complete

Daftar isi

Module: The Interface

Lesson: A Brief Introduction

Welcome to this course! We are going to show you how to use QGIS easily and efficiently. If you're new to GIS, we'll tell you what you need to get started. If you're an experienced user, you'll see how QGIS fulfills all the functions you expect from a GIS program, and more!

In this module we introduce the QGIS project itself, as well as explaining the user interface.

After completing this section, you will be able to correctly identify the main elements of the screen in QGIS and know what each of them does, and load a shapefile into QGIS.

Warning: This course includes instructions on adding, deleting and altering GIS datasets. We have provided training datasets for this purpose. Before using the techniques described here on your own data, always ensure you have proper backups!

How to use this tutorial

Any text that looks like this refers to something on the screen that you can click on.

Text that looks \rightarrow like \rightarrow this directs you through menus.

This kind of text refers to something you can type, such as a command, path, or file name.

Tiered course objectives

This course caters to different user experience levels. Depending on which category you consider yourself to be in, you can expect a different set of course outcomes. Each category contains information that is essential for the next one, so it's important to do all exercises that are at or below your level of experience.

Basic.png Basic

In this category, the course assumes that you have little or no prior experience with theoretical GIS knowledge or the operation of a GIS program.

Limited theoretical background will be provided to explain the purpose of an action you will be performing in the program, but the emphasis is on learning by doing.

When you complete the course, you will have a better concept of the possibilities of GIS, and how to harness their power via QGIS.

Moderate.png Intermediate

In this category, it is assumed that you have working knowledge and experience of the everyday uses of GIS.

Following the instructions for the beginner level will provide you with familiar ground, as well as to make you aware of the cases where QGIS does things slightly differently from other software you may be used to. You will also learn how to use analysis functions in QGIS.

When you complete the course, you should be comfortable with using QGIS for all of the functions you usually need from a GIS for everyday use.

Hard.png Advanced

In this category, the assumption is that you are experienced with GIS, have knowledge of and experience with spatial databases, using data on a remote server, perhaps writing scripts for analysis purposes, etc.

Following the instructions for the other two levels will familiarize you with the approach that the QGIS interface follows, and will ensure that you know how to access the basic functions that you need. You will also be shown how to make use of QGIS' plugin system, database access system, and so on.

When you complete the course, you should be well-acquainted with the everyday operation of QGIS, as well as its more advanced functions.


As information becomes increasingly spatially aware, there is no shortage of tools able to fulfill some or all commonly used GIS functions. Why should anyone be using QGIS over some other GIS software package?

Here are only some of the reasons:

  • It's free. Anyone can download it and use it - it costs nothing.
  • It's powerful - as powerful and sophisticated as most high-level, expensive GIS software packages you buy off the shelf.
  • It's open source which means you can sponsor the development of a feature, or add it yourself if you are familiar with programming. You are free to make it grow to suit your needs.
  • It's constantly developing. Because anyone can add new features and improve on existing ones, QGIS never stagnates. The development of a new tool can happen as quickly as you need it to.
  • Extensive help and documentation is available. If you're stuck with anything, you can turn to the extensive documentation, your fellow QGIS users, or even the developers.
  • Cross-platform. QGIS can be installed on MacOS, Windows and Linux.

Now that you know why you want to use QGIS, we can show you how. The first lesson will guide you in creating your first QGIS map.

Lesson: Adding your first layer

We will start the application, and create a basic map to use for examples and exercises.

The goal for this lesson: To get started with an example map.

Note: Before starting this exercise, QGIS must be installed on your computer. Download it now

Launch QGIS from its desktop shortcut, menu item, etc., depending on how you configured its installation.

Note:The screenshots for this course were taken in QGIS 1.8 running on Mac OS X 10.9.5. Depending on your setup, the screens you encounter may well appear somewhat different. However, all the same buttons will still be available, and the instructions will work on any OS. You will need QGIS 1.8 or above to use this course.

Let's get started right away!

Basic9.png Follow along: Prepare a map

  • Open QGIS. You will have a new, blank map.
  • Look for the Add Vector Layer button:


  • Click on it to open the following dialogue:


  • Click on the Browse button and navigate to the file exercise_data/streets.shp (in your course directory). With this file selected, click Open. You will see the original dialogue, but with the file path filled in. Click Open here as well. The data you specified will now load.

Congratulations! You now have a basic map. Now would be a good time to save your work.

  • Click on the Save As button:


  • Save the map under exercise_data/ and call it basic_map.qgs.

Check your results - Preparation

In conclusion

You've learned how to add a layer and create a basic map!

What's next?

Now you're familiar with the function of the Add Vector Layer button, but what about all the others? How does this interface work? Before we go on with the more involved stuff, let's first take a good look at the general layout of the QGIS interface. This is the topic of the next lesson.

Lesson: An Overview of the Interface

[introduction/overview::doc] We will explore the QGIS user interface so that you are familiar with the menus, toolbars, map canvas and layers list that form the basic structure of the interface.

The goal for this lesson: To understand the basics of the QGIS user interface.

Basic.png Try yourself...: The Basics


The elements identified in the figure above are:

  1. Layers list
  2. Toolbars
  3. Map canvas
  4. Status bar

Basic.png The Layers List

In the Layers list, you can see a list, at any time, of all the layers available to you.

Expanding collapsed items (by clicking the arrow or plus symbol beside them) will provide you with more information on the layer's current appearance.

Right-clicking on a layer will give you a menu with lots of extra options. You will be using some of them before long, so take a look around!

Some versions of QGIS have a separate Control rendering order checkbox just underneath the Layers list. Don't worry if you can't see it. If it is present, ensure that it's checked for now.

Note: A vector layer is a dataset, usually of a specific kind of object, such as roads, trees, etc. A vector layer can consist of either points, lines or polygons.

Basic.png Toolbars

Your most oft-used sets of tools can be turned into toolbars for basic access. For example, the File toolbar allows you to save, load, print, and start a new project. You can easily customize the interface to see only the tools you use most often, adding or removing toolbars as necessary via the View \rightarrow Toolbars menu.

Even if they are not visible in a toolbar, all of your tools will remain accessible via the menus. For example, if you remove the File toolbar (which contains the Save button), you can still save your map by clicking on the File menu and then clicking on Save.

Basic9.png The Map Canvas

This is where the map itself is displayed.

Basic9.png The Status Bar

Shows you information about the current map. Also allows you to adjust the map scale and see the mouse cursor's coordinates on the map.

Basic9.png Try yourself... 1

Try to identify the four elements listed above on your own screen, without referring to the diagram above. See if you can identify their names and functions. You will become more familiar with these elements as you use them in the coming days.

Basic9.png Try yourself... 2

Try to find each of these tools on your screen. What is their purpose?

  1. 0045.png
  2. 0054.png
  3. 0063.png
  4. 0074.png
  5. 0083.png

Hint: If any of these tools is not visible on the screen, try enabling some toolbars that are currently hidden. Also keep in mind that if there isn't enough space on the screen, a toolbar may be shortened by hiding some of its tools. You can see the hidden tools by clicking on the double right arrow button in any such collapsed toolbar. You can see a tooltip with the name of any tool by holding your mouse over the tool for a while.

What's next?

Now you've seen how the QGIS interface works, you can use the tools available to you and start improving on your map! This is the topic of the next lesson.

Module: Creating a Basic Map

In this module, you will create a basic map which will be used later as a basis for further demonstrations of QGIS functionality.

Lesson: Working with Vector Data

Vector data is arguably the most common kind of data you will find in the daily use of GIS. It describes geographic data in terms of points, that may be connected into lines and polygons. Every object in a vector dataset is called a feature, and is associated with data that describes that feature.

The goal for this lesson: To learn about the structure of vector data, and how to load vector datasets into a map.

Basic4.png Follow along: Viewing layer attributes

It's important to know that the data you will be working with does not only represent where objects are in space, but also tells you what those objects are.

From the previous exercise, you should have the streets layer loaded in your map. What you can see right now is merely the position of the roads.

To see all the data available to you:

  • Click on this button:


It will show you a table with more data about the streets layer. This extra data is called attribute data. The lines that you can see on your map represent where the streets go; this is the spatial data.

These definitions are commonly used in GIS, so it's essential to remember them!

  • You may now close the attribute table.

Vector data represents features in terms of points, lines and polygons on a coordinate plane. It is usually used to store discrete features, like roads and city blocks.

Basic4.png Follow along: Loading vector data from shapefiles

The Shapefile is a specific file format that allows you to store GIS data in an associated group of files. Each layer consists of several files with the same name, but different file types. Shapefiles are easy to send back and forth, and most GIS software can read them.

Refer back to the introductory exercise in the previous section for instructions on how to add vector layers.

  • Load the "waterways", "places" and "forests" datasets into your map following the same method.

Basic4.png Follow along: Loading vector data from a database

Databases allow you to store a large volume of associated data in one file. You may already be familiar with a database management system (DBMS) such as Microsoft Access. GIS applications can also make use of databases. GIS-specific DBMSes (such as PostGIS) have extra functions, because they need to handle spatial data.

  • Click on this icon:


(If you're sure you can't see it at all, check that the Manage Layers toolbar is enabled.)

It will give you a new dialogue. In this dialogue:

  • Click the New button.
  • In the same folder as the other data, you should find the file land_use.sqlite. Select it and click Open.

You will now see the first dialogue again. Notice that the dropdown select above the three buttons now reads "land_use.sqlite@...", followed by the path of the database file on your computer.

  • Click the Connect button. You should see this in the previously empty box:


  • Click on the layer to select it
  • Click Add

Note: Remember to save the map often! The map file doesn't contain any of the data directly, but it remembers which layers you loaded into your map.

Follow along: Reordering the layers

The layers in your Layers list are drawn on the map in a certain order. The layer at the bottom of the list is drawn first, and the layer at the top is drawn last. By changing the order that they are shown on the list, you can change the order they are drawn in.

Note: Depending on the version of QGIS that you are using, you may have a checkbox beneath your Layers list reading Control rendering order. This must be checked (switched on) so that moving the layers up and down in the Layers list will bring them to the front or send them to the back in the map. If your version of QGIS doesn't have this option, then it is switched on by default and you don't need to worry about it.

The order in which the layers have been loaded into the map is probably not logical at this stage.

For example, this layer order...


... would result in some places being hidden as they run underneath the land_use areas.

To resolve this problem:

  • Click and drag on a layer in the Layers list.
  • Reorder them to look like this:


In conclusion

Now you've added all the layers you need from several different sources.

What's next?

Using the random palette automatically assigned when loading the layers, your current map is probably not easy to read. It would be preferable to assign your own choice of colours and symbols. This is what you'll learn to do in the next lesson.

Lesson: Symbology

The symbology of a layer is its visual appearance on the map. The basic strength of GIS over other ways of representing data with spatial aspects is that with GIS, you have a dynamic visual representation of the data you're working with.

Therefore, the visual appearance of the map (which depends on the symbology of the individual layers) is very important. The end user of the maps you produce will need to be able to easily see what the map represents. Equally as important, you need to be able to explore the data as you're working with it, and good symbology helps a lot.

In other words, having proper symbology is not a luxury or just nice to have. In fact, it's essential for you to use a GIS properly and produce maps and information that people will be able to use.

The goal for this lesson: To create different symbology for any vector layer.

Basic4.png Follow along: Changing colours

To change a layer's symbology, open its Layer Properties. Let's begin by changing the colour of the waterways layer.

  • Right-click on the waterways layer in the Layers list.
  • Select the menu item Properties in the menu that appears.

Note: By default, you can also access a layer's properties by double-clicking on the layer in the Layers list.

In the Properties window:

  • Select the Style tab at the extreme left:


  • Click the Change button next to the colour label.

A standard colour dialogue will appear.

  • Choose a blue colour and click OK.
  • Click OK again in the Layer Properties window, and you will see the colour change being applied to the layer.


Basic4.png Try yourself...

Change the forest layer to a new colour that you associate with forests.

Basic4.png Follow along: Changing symbol structure

This is a good introduction, but there is more to a layer's symbology than just its colour. To learn about some of the other options available, add the layer bandung_districts. This layer has been made up of images originally taken by satellite, and showing various types of land cover in the area around Bandung.

Using this layer we can learn how to remove the lines so the map does not appear cluttered.

  • Open the Layer Properties window for the bandung_districts layer.

Under the Style tab, you will see the same kind of dialogue as before. This time, however, you're doing more than just quickly changing the colour.

  • Click on the Change... button below the colour display:


The Symbol properties dialogue will appear.

  • Change the colour inside the polygons in the layer by clicking the button next to the colour label (if you haven't done so already during the previous lesson).
  • In the dialogue that appears, choose a new colour.
  • Click OK, but only once.

Next, we want to get rid of the lines between the different types of land cover.

  • Click on the Border style dropdown. At the moment, it should be showing a short line and the words Solid Line.
  • Change this to No Pen.
  • Click OK, and then OK again.

Now the bandung_districts layer won't have any lines between the different areas of land cover.

Basic4.png Try yourself...

  • Change the bandung_districts layer again so that it has dotted outlines which are just a bit darker than the fill colour for that layer.

Moderate4.png Follow along: Scale-based visibility

Sometimes you will find that a layer is not suitable for a given scale. For example, a dataset of all the continents may have low detail, and not be very accurate at street level. When that happens, you want to be able to hide the dataset at inappropriate scales.

In our case, we may decide to hide the streets from view at small scales. This map, for example ...


... is not very useful. The streets are just a blob at that scale.

To enable scale-based rendering:

  • Open the Layer Properties dialogue for the streets layer.
  • Activate the General tab.
  • Enable scale-based rendering by clicking on the checkbox labeled Use scale dependent rendering:


  • Change the Maximum value to 100000.
  • Click OK.

Test the effects of this by zooming in and out in your map, noting when the streets layer disappears and reappears.

Note: You can use your mouse wheel to zoom in increments. Alternatively, use the zoom tools to zoom to a window:


Moderate4.png Follow along: Adding symbol layers

Now that you know how to change simple symbology for layers, the next step is to create more complex symbology. QGIS allows you to do this using symbol layers.

  • Go back to the bandung_districts layer's Symbol properties dialogue as before.

In this example, the current symbol has a dotted outline (i.e., it uses the Dot Line border style).


Note the highlighted button.

  • Click on it and the dialogue will change to look somewhat like this:


(It may appear somewhat different in colour, for example, but you're going to change that anyway.)

Now there's a second symbol layer. Being a solid colour, it will of course completely hide the previous kind of symbol. Plus, it has a Solid Line border style, which we don't want. Clearly this symbol has to be changed.

Note: It's important not to get confused between a map layer and a symbol layer. A map layer is a vector (or raster) that has been loaded into the map. A symbol layer is part of the symbol used to represent a map layer. This course will usually refer to a map layer as just a layer, but a symbol layer will always be called a symbol layer, to prevent confusion.

  • Set the border styles to No Pen.
  • Change the fill style to something other than Solid or No brush. For example:


  • Click OK in this dialogue and Apply in the one after that. Now you can see your results and tweak them as needed.

You can even add multiple extra symbol layers and create a kind of texture for your layer that way.


It's fun! But it probably has too many colours to use in a real map...

Moderate4.png Try yourself...

  • Create a simple, but not distracting texture for the forest layer using the methods above.

Moderate4.png Follow along: Enabling symbol levels

When symbol layers are rendered, they are also rendered in a sequence, similar to how the different map layers are rendered. This means that in some cases, having many symbol layers in one symbol can cause unexpected results.

  • Give the streets layer an extra symbol layer (using the method for adding symbol layers demonstrated above).
  • Give the base line a thickness of 0.5.
  • Give the top layer a thickness of 2.0.

You'll notice that this happens:


Well that's not what we want at all!

To prevent this from happening, you can enable symbol levels, which will control the order in which the different symbol layers are rendered.

  • In the Layer Properties dialogue, click on Advanced \rightarrow Symbol levels:


The Symbol Levels dialogue will appear.

  • Alter its values to match this example:


  • Click OK, then OK again.

The map will now look like this:


When you're done, remember to save the symbol itself so as not to lose your work if you change the symbol again in the future. You can save your current symbol style by clicking the Save Style ... button under the Style tab of the Layer Properties dialogue. Save your style under exercise_data/styles. You can load a previously saved style at any time by clicking the Load Style ... button. Before you change a style, keep in mind that any unsaved style you are replacing will be lost.

Moderate4.png Try yourself...

  • Change the appearance of the streets layer again.

The roads must be dark gray or black, with a thin yellow outline, and a dashed white line running in the middle to make them resemble a real road.


Hard.png Try yourself...

Symbol levels also work for classified layers (i.e., layers having multiple symbols). Since we haven't covered classification yet, you will work with some rudimentary preclassified data.

  • Create a new map and add only the streets dataset.
  • Apply the style advanced_street_style_demo.qml provided in exercise_data/styles.
  • Zoom into the layer so it is easier to see.
  • Using symbol layers, ensure that the outlines of layers flow into one another as per the image below:


Moderate.png Follow along: Symbol layer types

To continue with the exercise, open your original map again.

In addition to setting fill colours and using predefined patterns, you can use different symbol layer types entirely. The only type we've been using up to now was the Simple Fill type. The more advanced symbol layer types allow you to customize your symbols even further.

Each type of vector (point, line and polygon) has its own set of symbol layer types. First we will look at the types available for points.

Point symbol layer types

  • Change the symbol properties for the places layer:


  • You can access the various symbol layer types here:


  • Investigate the various options available to you, and choose a symbol layer type other than the default Simple Marker.

Line symbol layer types

To see the various options available for line data:

  • Change the symbol layer type for the street layer's "residential" layer:


  • Click on the Change button next to the Marker label.
  • Change the symbol properties to match this dialogue:


  • Change the interval to 2,00:


  • Ensure that the symbol levels are correct before applying the style.

Once you have applied the style, take a look at its results on the map. If you look closely, these symbols change direction along with the road but don't always bend along with it. This is useful for some purposes, but not for others. If you prefer, you can change the symbol layer in question back to the way it was before.

Polygon symbol layer types

To see the various options available for polygon data:

  • Change one or more of the symbol layer type for the bandung_districts layer, as before for the other layers.
  • Investigate what the different options on the list can do.
  • You can change each symbol by double-clicking on the symbol you want to change


  • In this particularl example we have categorised the data. You will learn more about this in the next chapter.
  • Choose one of them that you find suitable.
  • If in doubt, use a combination of two layers, using the Point pattern fill and a Simple fill:


  • Use the Symbol layer type Point pattern fill
  • The Marker should be a Simple marker
  • Choose an appropriate border and fill colour (this can be the same colour)
  • Choose an appropriate marker size
  • Click OK
  • Add a new symbol layer with a normal Simple fill.
  • Make it a contrasting colour to your first layer
  • Move it underneath the point pattern symbol layer with the Move down button:

As a result, you have a textured symbol for your chosen layers, with the added benefit that you can change the size, shape and distance of the individual dots that make up the texture. The following screenshot shows we have changed two layers using the above method.


In conclusion

Changing the symbology for the different layers can transformed a collection of vector files into a legible map. Not only can you see what's happening, it's even nice to look at!

You can even create your own, custom SVG fill using vector editing software such as Inkscape, which is freely available on the internet.

Further reading

Examples of Beautiful Maps[1]

What's next?

Changing symbols for whole layers is useful, but the information contained within each layer is not yet available to someone reading these maps. What are the streets called? Which administrative regions do certain areas belong to? What are the relative surface areas of the farms? All of this information is still hidden. The next lesson will explain how to represent this data on your map.

Note: Did you remember to save your map recently?

Module: Classifying Vector Data

Classifying vector data allows you to assign different symbols to features (different objects in the same layer), depending on their attributes. This allows someone who uses the map to easily see the attributes of various features.

Lesson: Attribute Data

Up to now, none of the changes we have made to the map have been influenced by the objects that are being shown. In other words, all the farms look alike, and all the roads look alike. When looking at the map, the viewers don't know anything about the roads they are seeing; only that there is a road of a certain shape in a certain area.

But the whole strength of GIS is that all the objects that are visible on the map, also have attributes. Maps in a GIS aren't just pictures. They represent not only objects in locations, but also information about those objects.

The goal of this lesson: To explore the attribute data of an object and understand what the various data can be useful for.

Basic.png Follow along: Attribute data

Open the attribute table for the places layer (refer back to the section "Working with Vector Data" if necessary). Which field would be the most useful to represent in label form, and why?

In conclusion

You now know how to use the attribute table to see what is actually in the data you're using. Any dataset will only be useful to you if it has the attributes that you care about. If you know which attributes you need, you can quickly decide if you're able to use a given dataset, or if you need to look for another one that has the required attribute data.

What's next?

Different attributes are useful for different purposes. Some of them can be represented directly as text for the map user to see. You'll learn how to do this in the next lesson.

Lesson: The Label Tool

Labels can be added to a map to show any information about an object. Any vector layer can have labels associated with it. These labels rely on the attribute data of a layer for their content.

Note: The Layer Properties dialogue does have a Labels tab, but for this example we will not be using it. It has too few options and may be difficult to work with, which is why it will probably be taken out of new versions of QGIS (after 1.8). Instead, for this lesson we'll use the separate Label tool, which has more options and is more user-friendly.

The goal for this lesson: To apply useful and good-looking labels to a layer.

Basic.png Follow along: Using labels

Before being able to access the Label tool, you will need to ensure that it has been activated.

  • Go to the menu item View \rightarrow Toolbars.
  • Ensure that the Label item has a check mark next to it. If it doesn't, click on the Label item, and it will be activated.
  • Click on the places layer in the Layers list, so that it is highlighted.
  • Click on the following toolbar button:


This gives you the Layer labeling settings dialogue.

  • Check the box next to Label this layer with....


You'll need to choose which field in the attributes will be used for the labels. In the previous lesson, you decided that the NAME field was the most suitable one for this purpose.

  • Click OK.

The map should now have labels like this:


Basic.png Follow along: Changing label options

What we have so far is good, but as you can see, the labels are overlapping the points that they are associated with. That doesn't look very nice. The text is also a bit larger than it needs to be. Let's fix these problems!

  • Open the Label tool again by clicking on its button as before.
  • Click on the ellipsis (...) button to change the text properties:


A standard text change dialogue appears, similar to those in many other programs. Change the font to Arial size 9. Your labels will now look like this:


This solves the font problem, and now let's look at the problem of the labels overlapping the points, but before we do that, let's take a look at the Buffer option.

  • Open the Label tool dialogue.
  • Deactivate the label buffer by clicking on the checkbox next to the text that says Buffer.
  • Click Apply.

Note the effects in the map:


Now you can see why we usually need label buffers!

  • Reactivate the buffers by clicking in the same checkbox as before, and then clicking Apply.

Back to the problem of the labels that overlap points.

  • In the Label tool dialogue, go to the Advanced tab.
  • Change the value of Label distance to 2.


  • Click Apply.

This is the result:


Moderate.png Follow along: Using labels instead of layer symbology

In many cases, the location of a point doesn't need to be very specific. For example, when they refer to entire towns or suburbs, and the specific point associated with such features is not that specific on a large scale. In fact, giving a point that is too specific is often confusing for someone reading a map.

To name an example: on a map of the world, the point given for the European Union may be somewhere in Poland, for instance. To someone reading the map, seeing a point labeled European Union in Poland, it may seem that the capital of the European Union is therefore in Poland.

So, to prevent this kind of misunderstanding, it's often useful to deactivate the point symbols and replace them completely with labels.

In QGIS, you can do this by changing the position of the labels to be rendered directly over the points they refer to.

  • Open the Layer labeling settings dialogue for the places layer.
  • Go to the Advanced tab.
  • Click on the over point button.


  • Hide the point symbols by editing the layer style as usual, and setting the size of points to 0:


  • Click OK and you'll see this result:


As you can see, some of the labels are now missing to prevent overlap (at this scale). Sometimes this is what you want when dealing with datasets that have many points, but at other times you will lose useful information this way. There is another possibility for handling cases like this, which we'll cover in a later exercise in this lesson.

Moderate.png Try yourself... Customize the labels

  • Return the label and symbol settings to the way they were before.
  • Set the map to the scale 1:20000. You can do this by typing it into the Scale box in the Status Bar.
  • Modify your labels to be suitable for viewing at this scale.

Moderate.png Follow along: Labeling lines

Now that you know how labeling works, there's an additional problem. Points and polygons are easy to label, but what about lines? If you label them the same way as the points, your results would look like this:


This is not very useful! To make lines behave, we'll need to edit some options.

  • Hide the places layer so that it doesn't distract you.
  • Zoom in on the town area.
  • Activate labels for the streets layer as before. (Remember to use the Label tool on the toolbar, not the one in Label Properties!)
  • Set the font Size to 9 so that you can see more labels.
  • In the Label tool dialogue's Advanced tab, choose the following settings:


The map will look somewhat like this, depending on scale:


It's better than before, but still not ideal. For starters, some of the names appear more than once, and that's not always necessary. To prevent that from happening:

  • Enable the option Merge connected lines to avoid duplicate labels (also under the Advanced tab - you may need to scroll down to see it).

Another useful function is to prevent labels being drawn for features too short to be of notice.

  • Set the value of Suppress labeling of features smaller than ... to 5mm and note the results when you click Apply.

Try out different Placement settings as well (also under the Advanced tab). As we've seen before, the horizontal option is not a good idea in this case, so let's try the curved option instead!

  • Select the curved option under the Advanced tab of the Layer labeling settings dialogue.

Here's the result:


As you can see, this hides a lot of the labels that were previously visible, because of the difficulty of making some of them follow twisting street lines and still be legible. You can decide which of these options to use, depending on what you think seems more useful or what looks better.

Hard.png Follow along: Data defined settings

  • Deactivate labeling for the streets layer.
  • Reactivate labeling for the places layer.
  • Open the attribute table for places.

It has two fields that are of interest to us now: AMENITY and RESTAURANT. AMENITY is what type of place it is. RESTAURANT is derived from it, and tells you whether or not that feature is a restaurant (1 if it is, 0 if not). We can use this data to influence the label styles.

  • Navigate to the Data defined settings tab.
  • In the Italic dropdown, select RESTAURANT and click Apply.

Notice its effects:


Hard.png Try yourself... Using data defined settings

{{hlbox:Note: We're jumping ahead a bit here to demonstrate some advanced labeling settings. At the advanced level, it's assumed that you'll know what the following means. If you don't, feel free to leave out this section and come back later when you've covered the requisite materials.}}

  • Open the attribute table for places.
  • Enter edit mode by clicking this button (at the lower edge of the attribute table):


  • Add a new column:


  • Configure it like this:


  • Use this to set custom font sizes for each different type of amenity (i.e., each key in the AMENITY field).

Hard.png Further possibilities with labeling

We can't cover every option in this course, but be aware that the Label tool has many other useful functions. You can set scale-based rendering, alter the rendering priority for labels in a layer, and set every label option using layer attributes. You can even set the rotation, XY position, and other properties of a label (if you have attribute fields allocated for the purpose), then edit these properties using the tools adjacent to the main Label tool:


(These tools will be active if the required attribute fields exist and you are in edit mode.)

Feel free to explore more possibilities of the labeling system.

In conclusion

You've learned how to use layer attributes to create dynamic labels. This can make your map a lot more informative and stylish!

What's next?

Now that you know how attributes can make a visual difference for your map, how about using them to change the symbology of objects themselves? That's the topic for the next lesson!

Lesson: Classification

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's say that someone wants to know what types of land cover are in the Bandung districts area. Using labels, you'd get this:


Obviously this is not ideal, so we need another solution. That's what this lesson is about!

The goal for this lesson: To learn how to classify vector data effectively.

Basic.png Follow along: Classifying nominal data

  • Open Layer Properties for bandung_districts
  • Go to the Style tab.
  • Click on the dropdown that says Single Symbol:


  • Change it to Categorized and the interface will change:


  • Change the Column to LANDCOVER and the colour ramp to random:


  • Click the button labeled Classify and then click OK.

You'll see something like this:


  • Click the arrow (or plus sign) next to bandung_districts in the Layer list, you'll see the categories explained:


So, this is useful! But it hurts your eyes to look at it, so let's see what we can do about that.

  • Open Layer Properties and go to the Style tab again.
  • Change the symbol:


  • Get rid of the outline the same way you did before, and click OK. (If you need to, go back to the lesson where we covered this to remember how it's done.)
  • Click the Delete all button:


This gets rid of the ugly classes so you can try again.

  • Choose a new option from the colour ramp
  • Click Classify again, and the new symbols will appear.

You'll notice they don't have outlines. This is because you just removed the outlines.

  • Change the colour for Water bodies by double-clicking on the coloured block representing its symbol:


Use your own colours, so that the resulting map isn't as ugly as the old one. In the example, we'll use these colours, with our water bodies coloured blue:


This gives us a nice map:


There is one category that is empty:


  • Select the empty category.
  • Click the Delete button.

This only gets rid of the symbol, not the data, so don't worry about messing up; you're not actually deleting anything that you can't recover.

Remember to save your map now so that you don't lose all your hard-earned changes!

Basic.png Try yourself... More classification

If you're only following the basic-level content, use the knowledge you gained above to classify the urban areas. Use darker colours to set them apart from the farms.

Moderate.png Follow along: Ratio classification

There 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.

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.

In interval classification, the numbers are on a scale with positive, negative and zero values. For example: height above/below sea level, temperature above/below freezing (0 degrees Celsius), etc.

In ratio classification, the numbers are on a scale with only positive and zero values. For example: temparature above absolute zero (0 degrees Kelvin), distance from a point, the average amount of traffic on a given street per month, etc.

In the example above, we used nominal classification to show different land cover areas. Now we will begin a new project, and look at ratio classification to classify villages by area.

  • Save your rural symbology (if you want to keep it) by clicking on the Save Style ... button in the Style dialogue.
  • Close the Style dialogue.
  • Save and close your current project.

Now we will begin our new exercise.

  • Open a new, blank project
  • Open the layers Sulawesi_dist_32750 and VillagePolyBarSin_32750.
  • Change the colour styles if necessary.

We want to classify these villages by area, but there is a problem: they do not have an area field! We will have to make one.

  • Enter edit mode by clicking this button:


  • Add a new column with this button:


  • Set up the dialogue that appears, like this:


  • Click OK.

The new field will be added (at the far right of the table; you may need to scroll horizontally to see it). However, at the moment it is not populated, it just has a lot of NULL values.

To solve this problem, we'll need to calculate the areas.

  • Open the field calculator:


You'll get this dialogue:


  • Change the values at the top of the dialogue to look like this:


  • In the Function List, select Geometry \rightarrow $area:


  • Double-click on it so that it appears in the Expression field.
  • Click OK.

Now your AREA field is populated with values! Admire them, then close the attribute table.

Note: These areas are in degrees area. Later, we will compute them in square meters.

  • Open the Layer properties dialogue's Style tab.
  • Change the classification style from Classified to Graduated:


  • Change the Column to AREA:


  • Under colour ramp, choose the option New colour ramp... to get this dialogue:


  • Choose Gradient (if it's not selected already) and click OK. You'll see this:


You'll be using this to denote area, with small areas as colour 1 and large areas as colour 2.

  • Choose appropriate colours.

In the example, the result looks like this:


  • Click OK.
  • Choose a suitable name for the new colour ramp.
  • Click OK after filling in the name.

Now you'll have something like this:


Leave everything as-is.

  • Click Apply:


Moderate.png Try yourself... Refine the classification

  • Get rid of the lines between the classes.
  • Change the values of Mode and Classes until you get a classification that makes sense.

Hard.png Follow along: Rule-based classification

It's often useful to combine multiple criteria for a classification, but unfortunately normal classification only takes one attribute into account. That's where rule-based classification comes in handy.

  • Open the Layer Properties dialogue for the rural layer.
  • Switch to the Style tab.
  • Switch the classification style to Rule-based. You'll get this:


  • Click the Add button.
  • A new dialogue that appears.
  • Click the ellipsis ... button next to the Filter text area.
  • Using the query builder that appears, enter the criterion AREA >= 30000000 and choose a light colour for it.
  • Add the criterion AREA <= 30000000 and choose a dark colour.
  • Add the criterion DESA = 'Ajakkang' and assign it the colour black, with transparency at 35%.
  • Use the Rendering order to render the layers correctly so Ajakkang is visible.

Your dialogue should look like this:


  • Apply this symbology.

Your map will look like this:


Now you have two area classes, with the village Ajakkang highlighted.

In conclusion

Symbology allows us to represent the attributes of a layer in an easy-to-read way. It allows us as well as the map reader to understand the significance of features, using any relevat attributes that we choose. Depending on the problems you face, you'll apply different classification techniques to solve them.

What's next?

Now we have a nice-looking map, but how are we going to get it out of QGIS and into a format we can print out, or make into an image or PDF? That's the topic of the next lesson!

Module: Creating Maps

In this module, you'll learn how to use the QGIS Map Composer to produce quality maps with all the requisite map components.

Lesson: Using Map Composer

Now that you've got a map, you need to be able to print it or to export it to a document. The reason is, a GIS map file is not an image. It saves the state of the GIS program, with references to all the layers, their labels, colours, etc. So for someone who doesn't have the data or the same GIS program (such as QGIS), the map file will be useless. Luckily, QGIS can export its map file to a format that anyone's computer can read, as well as printing out the map if you have a printer connected. Both exporting and printing is handled via the Map Composer.

The goal for this lesson: To use the QGIS Map Composer to create a basic map with all the required settings.

Basic.png Follow along: The Composer Manager

QGIS allows you to create multiple maps using the same map file. For this reason, it has a tool called the Composer Manager.

  • Zoom in on the area of your map showing the streets and places of Bandung.
  • Click on the File \rightarrow Composer Manager menu entry to open this tool. You'll see a blank Composer manager dialogue appear.
  • Click the Add button and a new composer will be added called Composer 1 (it may be another number if you have tried using the Composer Manager before now).
  • With your new composer selected, click on the Rename button and rename it to Bandung.
  • Click OK.
  • Click the Show button.

(You could also close the dialogue and navigate to a composer via the File \rightarrow Print Composers menus, as in the image below.)


Whichever route you take to get there, you will now see the Print Composer window.

Basic.png Follow along: Basic Map Composition

In this example, the composition was already the way we wanted it. Ensure that yours is as well.

  • Check that the values under General \rightarrow Composition \rightarrow Paper and Quality are set to the following:
  • Size: A4 (210x297mm)
  • Orientation: Landscape
  • Quality: 300dpi

Now you've got the page layout the way you wanted it, but this page is still blank. It clearly lacks a map. Let's fix that!

  • Click on the Add New Map button:


With this tool activated, you'll be able to place a map on the page.

  • Click and drag a box on the blank page:


The map will appear on the page.

  • Move the map by clicking and dragging it around:


  • Resize it by clicking and dragging the boxes in the corners:


Note: Your map may look a lot different, of course! This depends on how your own project is set up. But not to worry! These instructions are general, so they will work the same regardless of what the map itself looks like.

  • Be sure to leave margins along the edges, and a space along the top for the title:


  • Zoom in and out on the page (but not the map!) by using these buttons:


  • Zoom and pan the map in the main QGIS window. You can also pan the map using the Move item content tool:


When zooming in, the map view will not refresh by itself. This is so that it doesn't waste your time redrawing the map while you're zooming the page to where you want it, but it also means that if you zoom in or out, the map will be at the wrong resolution and will look ugly or unreadable.

  • Force the map to refresh by clicking this button:


Remember that the size and position you've given the map doesn't need to be final. You can always come back and change it later if you're not satisfied. For now, you need to ensure that you've saved your work on this map. Because a Composer in QGIS is part of the main map file, you'll need to save your main project. Go to the main QGIS window (the one with the Layers list and all the other familiar elements you were working with before), and save your project from there as usual.

Basic.png Follow along: Adding a Title

Now your map is looking good on the page, but the reader is not being told what's going on yet. They need some context, which is what you'll provide for them by adding map elements. First, let's add a title.

  • Click on this button:


  • Click on the page, and a label will appear:


  • Resize it and place it in the top center of the page. It can be resized and moved in the same way that you resized and moved the map.


But if you tried it, you'll see that it's difficult to align the label to be completely centered to the map! Luckily, there's a tool for that.

  • Click the map to select it.
  • Hold in shift on your keyboard and click on the label.
  • Look for this tool (but don't click it yet):


  • Click on the downwards arrow next to the button.
  • Click Align center:


To make sure that you don't accidentally move these elements around now that you've aligned them:

  • Right-click on both the map and the label.

A small lock icon will appear in the corner to tell you that an element can't be dragged right now. You can always right-click on an element again to unlock it, though.

Now the label is centered to the map, but not the contents. To center the contents of the label:

  • Select the label by clicking on it.
  • Click on the Item tab in the side panel of the Composer window.
  • Change the text of the label to "Bandung":


  • Use this interface to set the font and alignment options:


  • Choose a large but sensible font (the example will use the default font with a size of 36), and keep the colour subdued.

In fact, it's probably best to keep it black as per the default. The key is that the font should not be distracting, otherwise people who see the page will be looking at the heading instead of reading the map!

  • Set the Horizontal Alignment to Center, so that the heading is properly centered within the label.


This is progressing nicely, but the label still has an unnecessary frame around it:


Let's get rid of it.

  • Click on the General options slider at the bottom of the Item tab. The Label slider will slide away and you will see a new interface.
  • Click the Show frame checkbox to disable the frame:


Here is our page so far:


Basic.png Follow along: Adding a Legend

The map reader also needs to be able to see what various things on the map actually mean. In some cases, like the place names, this is quite obvious. In other cases, it's more difficult to guess, like the colours of the farms. Let's add a new legend.

  • Click on this button:


  • Click on the page to place the legend, and move it to where you want it:


In this example, the legend is far too big. We will now learn how to customize the legend.

Moderate.png Follow along: Customizing Legend Items

Not everything on the legend is necessary, so let's remove some unwanted items.

  • In the Item tab, click on the Legend items slider.
  • Select the places entry.
  • Delete it from the legend by clicking the minus button:


  • Remove any other items that you don't think are necessary.

You can also rename items.

  • Select a layer from the same list.
  • Click the Edit button:


  • Rename the layers to Roads and Streets, Water ways, and Land cover.
  • Click the down arrow next to any item with multiple classes to rename the classes (using the same method as above).
  • Remove any layers not necessary (for example, areas of land cover that are

not displayed on the map).

This is the result in the example. We have moved the legend to the side of the map and realigned the title with the map:


Basic.png Follow along: Exporting Your Map

Note: Did you remember to save your work often?

Finally the map is ready for export! You'll see the export buttons near the top left corner of the Composer window:


The button on the right is the Print button, which interfaces with a printer. Since the printer options will differ depending on the model of printer that you're working with, it's probably better to consult the printer manual or a general guide to printing for more information on this topic.

The other three buttons allow you to export the map page to a file. There are three export formats to choose from:

  • Export as Image
  • Export as PDF
  • Export as SVG

Exporting as an image will give you a selection of various common image formats to choose from. This is probably the simplest option, but the image it creates is "dead" and difficult to edit.

The other two options are more common.

If you're sending the map to a cartographer (who may want to edit the map for publication), it's best to export as an SVG. SVG stands for "Scalable Vector Graphic", and can be imported to programs like Inkscape or other vector image editing software.

If you need to send the map to a client, it's most common to use a PDF, because it's easier to set up printing options for a PDF. Some cartographers may prefer PDF as well, if they have a program that allows them to import and edit this format.

For our purposes, we're going to use PDF.

  • Click the Export as PDF button:


  • Choose a save location and a file name as usual.
  • Click Save.

In conclusion

  • Close the Composer window.
  • Save your map.
  • Find your exported PDF using your operating system's file manager.
  • Open it.
  • Bask in its glory.

Congratulations on your first completed QGIS map project!

What's next?

On the next page, you will be given an assignment to complete. This will allow you to practice the techniques you have learned so far.

Assignment 1

Open your existing map project and revise it thoroughly. If you have noticed small errors or things you'd have liked to fix earlier, do so now.

If you are following this course at a Basic or Intermediate level, try to understand and implement techniques taught at a higher level.

While customizing your map, keep asking yourself questions. Is this map easy to read and understand for someone who's unfamiliar with the data? If I saw this map on the Internet, or on a poster, or in a magazine, would it capture my attention? Would I want to read this map if it wasn't mine?

If you're doing this course at a image Basic or image Intermediate level, read up on techniques from the more advanced sections. If you see something you'd like to do in your map, why not try to implement it?

If this course is being presented to you, the course presenter may require you to submit a final version of your map, exported to PDF, for evaluation. If you're doing this course by yourself, it's recommended that you evaluate your own map using the same criteria. Your map will be evaluated on the overall appearance and symbology of the map itself, as well as the appearance and layout of the map page and elements. Remember that the emphasis for evaluating the appearance of maps will always be ease of use. The nicer the map is to look at and the easier it is to understand at a glance, the better.

Happy customizing! :)

In conclusion

The first four modules have taught you how to create and style a vector map. In the next four modules, you'll learn how to use QGIS for a complete GIS analysis. This will include creating and editing vector data; analyzing vector data; using and analyzing raster data; and using GIS to solve a problem from start to finish, using both raster and vector data sources.

Module: Creating Vector Data

Creating maps using existing data is just the beginning. In this module, you'll learn how to modify existing vector data and create new datasets entirely.

Lesson: Creating a New Vector Dataset

The data that you use has to come from somewhere. For most common applications, the data exists already; but the more particular and specialized the project, the less likely it is that the data will already be available. In such cases, you'll need to create your own new data.

The goal for this lesson: To create a new vector dataset.

Basic.png Follow along: The Layer Creation dialogue

Before you can add new vector data, you need a vector dataset to add it to. In our case, you'll begin by creating new data entirely, rather than editing an existing dataset. Therefore, you'll need to define your own new dataset first.

You'll need to open the New Vector Layer dialogue that will allow you to define a new layer.

  • Navigate to and click on the menu entry Layer \rightarrow New \rightarrow New Shapefile Layer.

You'll be presented with the following dialogue:


It's important to decide which kind of dataset you want at this stage. Each different vector layer type is "built differently" in the background, so once you've created the layer, you can't change its type.

For the next exercise, we're going to be creating new features which describe areas. For such features, you'll need to create a polygon dataset.

  • Click on the Polygon radio button:


This has no impact on the rest of the dialogue, but it will cause the correct type of geometry to be used when the vector dataset is created.

The next field allows you to specify the Coordinate Reference System, or CRS. A CRS specifies how to describe a point on Earth in terms of coordinates, and because there are many different ways to do this, there are many different CRSs. The CRS of this project is WGS84, so it's already correct by default:


Next there is a collection of fields grouped under New attribute. By default, a new layer has only one attribute, the id field (which you should see in the Attributes list) below. However, in order for the data you create to be useful, you actually need to say something about the features you'll be creating in this new layer! For our current purposes, it will be enough to add one field called name.

  • Replicate the setup below, then click the Add to attributes list button:


  • Check that your dialogue now looks like this:


  • Click OK. A save dialogue will appear.
  • Navigate to the exercise_data directory.
  • Save your new layer as university_property.shp.

The new layer should appear in your Layers list.

Basic.png Follow along: Data sources

When you create new data, it obviously has to be about objects that really exist on the ground. Therefore, you'll need to get your information from somewhere.

There are many different ways to obtain data about objects. For example, you could use a GPS to capture points in the real world, then import the data into QGS afterwards. Or you could survey points using a theodolite, and enter the coordinates manually to create new features. Or you could use the digitizing process to trace objects off of remote sensing data, such as satellite imagery or aerial photography.

For our example, you'll be using the digitizing approach. Sample raster datasets are provided, so you'll need to import them as necessary.

  • Click on the Add Raster Layer button:


  • Navigate to exercise_data/raster/.
  • Select the file ITB_raster.tif.
  • Click Open. An image will load into your map.
  • Find the new image in the Layers list.


You'll be digitizing these three fields:


  • Hide all the layers except the raster and the university_property layer.

In order to begin digitizing, you'll need to enter edit mode. GIS software commonly requires this to prevent you from accidentally editing or deleting important data. Edit mode is switched on or off individually for each layer.

To enter edit mode for the university_property layer:

  • Right click on the layer in the Layer list to select it. (Make very sure that the correct layer is selected, otherwise you'll edit the wrong layer)
  • Click on the Toggle Editing button:


If you can't find this button, check that the Digitizing toolbar is enabled. There should be a check mark next to the View \rightarrow Toolbars \rightarrow Digitizing menu entry.

As soon as you are in edit mode, you'll see the digitizing tools are now active:


From left to right on the image above, they are:

  • Toggle Edit: activates / deactivates edit mode.
  • Save Edits: saves changes made to the layer.
  • Add Feature: start digitizing a new feature.
  • Move Feature(s): move an entire feature around.
  • Node Tool: move only one part of a feature.
  • Delete Selected: delete the selected feature (only active if a feature is selected).
  • Cut Features: cut the selected feature (only active if a feature is selected).
  • Copy Features: copy the selected feature (only active if a feature is selected).
  • Paste Features: paste a cut or copied feature back into the map (only active if a feature has been cut or copied).

You want to add a new feature.

  • Click on the Add Feature button now to begin digitizing right away!

You'll notice that your mouse cursor has become a crosshair. This allows you to more accurately place the points you'll be digitizing. Remember that even as you're using the digitizing tool, you can zoom in and out on your map by rolling the mouse wheel, and you can pan around by holding down the mouse wheel and dragging around in the map.

The first feature you'll be digitizing is the tennis courts:


  • Start digitizing by clicking on a point somewhere along the edge of the field.
  • Place more points by clicking further along the edge, until the shape you're drawing completely covers the field.
  • To place your last point, right-click where you want it to be. This will finalize the feature and show you the Attributes dialogue.
  • Fill in the values as below:


  • Click OK and you've created a new feature!

Remember, if you've made a mistake while digitizing a feature, you can always edit it after you're done creating it. If you've made a mistake, continue digitizing until you're done creating the feature as above. Then:

  • Select the feature with the Select Single Feature tool:


You can use:

  • the Move Feature(s) tool to move the entire feature,
  • the Node Tool to move only one point where you may have misclicked,
  • Delete Selected to get rid of the feature entirely so you can try again, and
  • the Edit \rightarrow Undo menu item or the ctrl + z keyboard shortcut to undo mistakes.

Basic.png Try yourself...

  • Digitize the athletics field and the swimming pools. Use this image to assist you:


Remember that each new feature needs to have a unique id value.

Note: When you're done adding features to a layer, remember to save your edits and then exit edit mode.

In conclusion

This lesson has shown you how to create new features in your dataset. This course doesn't cover adding point features, because that's not really necessary now you have worked with more complicated features (lines and polygons). Adding point features works exactly the same, except that you only click once where you want the point to be, give it attributes as usual, and then the feature is created.

Knowing how to digitize is important because it's a very common activity in GIS programs.

What's next?

Now that you have been introduced to vector data creation, you can learn how to analyze this data to solve problems. That is the topic of the next module.

Module: Vector Analysis

Now that you have edited a few features, you must want to know what else one can do with them. Having features with attributes is nice, but when all is said and done, this doesn't really tell you anything that a normal, non-GIS map can't.

The key advantage of a GIS is this: a GIS can answer questions.

For the next three modules, we will show you the functions of a GIS that you can use to answer a research question similar to what you may be asked to do as part of your job. This will include:

  • projecting layers according to your needs
  • using Simple Query Language (SQL) to find particular data
  • creating buffers
  • finding data contained in more than one layer using the Intersect tool
  • find data using the Select by location tool

Lesson: Reprojecting and Transforming Data

Let us talk about Coordinate Reference Systems (CRSs) again. We have touched on this briefly before, but have not discussed what it means practically.

The goal for this lesson: To reproject and transform vector datasets.

Basic.png Follow along: Projections

The CRS that all the data as well as the map itself are in right now is called WGS84. This is a very common Geographic Coordinate System (GCS) for representing data. But there's a problem, as we will see.

  • Save your current map.
  • Then open the map of the world which you'll find under exercise_data/world/world.qgs.
  • Zoom in to Indonesia by using the Zoom In tool.
  • Try setting a scale in the Scale field, which is in the Status Bar along the bottom of the screen. While over Indonesia, set this value to 1:5000000 (one to five million).
  • Pan around the map while keeping an eye on the Scale field.

Notice the scale changing? That's because you're moving away from the one point that you zoomed into at 1:5000000, which was at the center of your screen. All around that point, the scale is different.

To understand why, think about a globe of the Earth. It has lines running along it from North to South. These longitude lines are far apart at the equator, but they meet at the poles.

In a GCS, you're working on this sphere, but your screen is flat. When you try to represent the sphere on a flat surface, distortion occurs, similar to what would happen if you cut open a tennis ball and tried to flatten it out. What this means on a map is that the longitude lines stay equally far apart from each other, even at the poles (where they are supposed to meet). This means that, as you travel away from the equator on your map, the scale of the objects that you see gets larger and larger. What this means for us, practically, is that there is no constant scale on our map.

To solve this, we will use a Projected Coordinate System (PCS) instead. A PCS "projects" or converts the data in a way that makes allowance for the scale change and corrects it. Therefore, to keep the scale constant, we should reproject our data to use a PCS.

Basic.png Follow along: "On the Fly" Reprojection

QGIS allows you to reproject data "on the fly". What this means is that even if the data itself is in another CRS, QGIS can project it as if it were in a CRS of your choice.

  • To enable "on the fly" projection, click on the CRS Status button in the Status Bar along the bottom of the QGIS window:


  • In the dialogue that appears, check the box next to Enable "on the fly' CRS transformation.
  • Type the word global into the Filter field. One CRS (NSIDC EASE-Grid Global) will appear in the list below.
  • Click on it to select it, then click OK.
  • Notice how the shape of Indonesia changes. All projections work by changing the apparent shapes of objects on Earth.
  • Zoom in to a scale of 1:5000000 again, as before.
  • Pan around the map.
  • Notice how the scale stays the same!

"On the fly" reprojection is also used for combining datasets that are in different CRSs.

  • Deactivate "on the fly" reprojection again:
    • Click on the CRS Status button again.
    • Uncheck the Enable "on the fly" CRS transformation box.
    • Clicking OK.
  • Add another vector layer to your map which has the data for Indonesia only. You will find it as exercise_data/world/Indonesia_regions_32750.shp.

What do you notice?

The layer is not visible! But that is easy to fix, right?

  • Right-click on the layer in the Layers list.
  • Select Zoom to Layer Extent.

So now we see Indonesia... but where is the rest of the world?

It turns out that we can zoom between these two layers, but we can not ever see them at the same time. That is because their Coordinate Reference Systems are so different. The continents dataset is in degrees, but the Indonesia_regions_32750 dataset is in meters. So, let us say that a given point in Jakarta in the Indonesia_regions_32750 dataset is about 620 000 meters away from the equator. But in the continents dataset, that same point is about 6.3 degrees away from the equator.

This is the same distance - but QGIS doesn't know that. You haven't told it to reproject the data. So as far as it's concerned, the version of Indonesia that we see in the Indonesia_regions_32750 dataset has Jakarta at the correct distance of 620 000 meters from the equator. But in the continents dataset, Jakarta is only 6.3 meters away from the equator! You can see why this is a problem.

QGIS does not know where Jakarta is supposed to be - that is what the data should be telling it. If the data tells QGIS that Jakarta is 6.3 meters away from the equator and that Indonesia is only about 12 meters from north to south, then that is what QGIS will draw.

To correct this:

  • Switch Enable "on the fly' CRS transformation on again as before.
  • Zoom to the extents of the Indonesia_regions_32750 dataset.

Now, because they are made to project in the same CRS, the two datasets fit perfectly:


When combining data from different sources, it is important to remember that they might not be in the same CRS. "On the fly" reprojection helps you to display them together.

Moderate.png Follow along: Saving a Dataset to Another CRS

We have shown how using "On the fly" can make layers with different projections appear on the same map. But how can we reproject the layers so they are the same projection?

To truly reproject the data itself, you need to export it to a new file using a new projection.

Our layer Indonesian_regions_32750 is projected using the CRS WGS 84 / UTM zone 50S, which is correct for most of Indonesia. What we will do now is reproject this layer so it is the same as our continents layer.

  • Right-click on the Indonesian_regions_32750
  • Click on Save as
  • A new window Save vector layer as... will appear
  • Click on the Browse button next to the Save as field
  • Navigate to your exercise_data/ folder, and call your new file Indonesia_regions_WGS84.shp
  • Leave the Encoding unchanged.
  • Change the value of the Layer CRS dropdown to Selected CRS.
  • Click the Browse button beneath the dropdown.
  • The CRS Selector dialogue will now appear.
  • In its Filter field, search for 33S.
  • Choose WGS 84 EPSG:4326 from the list.
  • Click OK.

The Save vector layer as... dialogue now looks like this:


  • Click OK and after an instant, you should be presented with:


  • Click OK.

Now both layers have the same projection and are displayed correctly, without the need for "On the fly".

Both the layers are now projected in degrees. If you want to measure distance using units of length such as meters or kilometers, you will need to project the layers accordingly, using a different PCS.

Note: It is very important to remember that to reproject a layer, you must save it as a new layer, with the new projection. You can not correctly change the projection of a layer using any other way.

In conclusion

Different projections are useful for different purposes. By choosing the correct projection, you can ensure that the features on your map are being represented accurately.


In conclusion

Different projections are useful for different purposes. By choosing the correct projection, you can ensure that the features on your map are being represented accurately.

Further reading

Further information on Coordinate Reference Systems is available here[2].

What's next?

In the next lesson you'll learn how to analyze vector data using QGIS' various vector analysis tools.

Lesson: Vector Analysis

Vector data can also be analyzed to reveal how different features interact with each other in space. There are many different analysis-related functions in GIS, so we won't go through them all. Instead, we will show show you the tools QGIS provides to solve a realistic problem you might face.

Note: For this lesson we are going to use the original exercise and data, which is based in South Africa. You will have the opportunity in Chapter 9, Using QGIS in animal health, to use GIS for a specific animal health exercise using Indonesian data from iSIKHNAS.

The goal for this lesson: To ask a question and solve it using analysis tools.

Basic.png The GIS Process

Before we start, it would be useful to give a brief overview of a process that can be used to solve any GIS problem. The way to go about it is:

  1. State the Problem
  2. Get the Data
  3. Analyze the Problem
  4. Present the Results

Basic.png The problem

We begin the process by deciding on a problem to solve. Let us say you are a property developer, and you need to buy a farm to build a new residential development for people who have had enough of Cape Town and Johannesburg. You have done some market research, and you have come up with the following requirements that a farm needs to satisfy:

  1. It needs to be in Swellendam.
  2. You don't want to have to build a long access road (maximum distance 500 meters), and it has to be easily accessible from main routes.
  3. The people who make up the target market will probably have children, so it must be within a reasonable distance (by car) from a school.
  4. The farm must be between 100 and 150 hectares in area.

Basic.png The data

To answer these questions, we are going to need the following data:

  1. The farms we're going to be choosing from.
  2. The roads that need to be running through these farms.
  3. The location of schools.

For this exercise the data has been provided already, but in reality you may need to find a provider for the datasets in question.

Basic.png Follow along: Start a Project

So now that we know what we want to do, let's start doing it!

  • Start a new QGIS project.
  • Start adding new layers. They're all to be found in the exercise_data/projected_data folder.
  • Add the schools_33S, roads_33S and farms_33S layers.

These files are in a Projected Coordinate System, which is necessary for this analysis, for reasons we have covered in the previous lesson. (We want to be able to calculate distances in meters and areas in hectares, not in degrees.)

Once you have got these layers in your Layers list:

  • Rename the layers by right-clicking on them and selecting the Rename option.
  • Give them the new, less messy names roads, schools and farms.
  • Save your map under exercise_data, as analysis.qgs.
  • In your operating system's file manager, create a new folder under exercise_data and call it residential_development. This is where you'll save the datasets that will be the results of the analysis functions.

Now that we've got the data, we can analyze the problem.

Basic.png Follow along: Analyzing the Problem: Farms in Swellendam

The first criterion we are facing is that the farm needs to be in Swellendam. So let's tell QGIS to only show us the farms that are, in fact, in Swellendam.

  • Right-click on the farms layer in the Layers list.
  • Select the option Query.... This gives you a new Query Builder dialogue.
  • Scroll down in the Fields list on the left of this dialogue until you see the field TOWN.
  • Click on it once.
  • Click the All button underneath the Values list:


Now we need to tell QGIS to only show us the farms where the value of TOWN is equal to Swellendam.

  • Double-click the word TOWN in the Fields list.
  • Watch what happens in the SQL where clause field below:


The word TOWN has appeared! To build the rest of the query:

  • Click the = button (under Operators).
  • Double-click the value Swellendam in the Values list.

Your query is this:


And now your farms layer looks like this:


For further analysis, it's better if we've got these farms as a separate layer.

  • Right-click on the farms layer and click Save As....
  • Next to the Save as field in the dialogue that appears, click the Browse button.
  • Save the layer under exercise_data/residential_development/, as swellendam_farms.shp.
  • Check the Add saved file to map box in the Save vector layer as... dialogue.
  • Click OK. It will tell you that Export to vector file has been completed.
  • Click OK.

Now we've got the farms twice, but we only need the one we just created.

  • Right-click on the old farms layer and remove it.

Basic.png Try yourself... find important roads

We have a similar problem with the roads; the only roads we're taking into account are the main ones.

  • Build a query for the roads layer, like you did above for the farms layer. You want only the types primary, secondary, tertiary and trunk, so you need to build this query:</p>

TYPE = 'primary' OR TYPE = 'secondary' OR TYPE = 'tertiary' OR TYPE = 'trunk' You can either use the approach above, where you double-clicked values and clicked buttons, or you can copy and paste the command above.

Basic.png Try yourself... find high schools

Your future customers will want to send their children to high schools.

  • Use the same approach as before and build this query for the schools layer:

has_high_s = 'y' You should have only 3 out of the 4 original schools left.

  • Save the resulting layer under exercise_data/residential_development/ as high_schools.shp.

Basic.png Follow along: Analyzing the Problem: Distances From Schools and Roads

QGIS allows you to calculate distances from any vector object.

  • Make sure that only the important_roads and swellendam_farms layers are visible, to simplify the map while you're working.
  • Click on the Vector \rightarrow Geoprocessing Tools \rightarrow Buffer(s) tool:


This gives you a new dialogue.

  • Set it up like this:


The Buffer distance is in meters because our input dataset is in a Projected Coordinate System. This is why we needed to use projected data!

  • Save the resulting layer under exercise_data/residential_development/ as important_roads_buffer_500m.shp.
  • Click OK and it will create the buffer.
  • When it asks you if it should "add the new layer to the TOC", click Yes. ("TOC" stands for "Table of Contents", by which it means the Layers list).
  • Now click on Close on the dialogue box.

Now you've got this:


OK, that looks interesting! Those are all the areas that are within 500 meters of an important road.

But look closer: it looks like there are joins between different sections of road! That is not nice. Remove that layer and let us try again:


  • Note that we're now checking the Dissolve buffer results box.
  • Save the output under the same name as before (click Yes when it asks your permission to overwrite the old one).
  • Click OK.

Once you've added the layer to the Layers list, it will look like this:


That's more like it! Now there are no unnecessary subdivisions.

Basic.png Try yourself... distance from high schools

  • Use the same approach as above and create a buffer for your schools.

It needs to be 10 km in radius, and saved under the usual directory as high_schools_buffer_10km.shp.

Basic.png Follow along: Overlapping Areas

Now we have areas where the road in 500 meters away and there's a school within 10 km (as the crow flies). But obviously, we only want the areas where both of these criteria are satisfied at once! To do that, we'll need to use the Intersect tool. Find it under Vector \rightarrow Geoprocessing Tools \rightarrow Intersect. Set it up like this:


The two input layers are the two buffers; the save location is as usual; and the file name is road_school_buffers_intersect.shp. Once it's set up like this, click OK and add the layer to the Layers list when prompted.

In the image below, the blue areas show us where both distance criteria are satisfied at once!


You may remove the two buffer layers and only keep the one that shows where they overlap, since that's what we really wanted to know in the first place.

Basic.png Follow along: Select the Farms

Now you've got the area that the farms must overlap. Next, you want to select the farms in that area.

  • Click on the menu entry Vector \rightarrow Research Tools \rightarrow Select by location. A dialogue will appear.
  • Set it up like this:


  • Click OK and you'll see the results:


The yellow farms are the selected ones. Let's save them as a new layer.

  • Right-click on the swellendam_farms layer in the Layers list.
  • Select Save Selection As....
  • Set the dialogue up like this:


  • The file name is well_located_farms.shp.
  • Click OK.

Now you have the selection as a separate layer.

Basic.png Follow along: Select Farms of the Right Size

To see which farms are the right area (between 100 and 150 ha), we first need to calculate their areas in hectares.

  • Open the attribute table for the well_located_farms layer.
  • Enter edit mode:


  • Start the field calculator:


  • Set it up like this:


  • If you can not find AREA in the list, try this instead:


  • Click OK.
  • Scroll to the right of the attribute table; your AREA field now has areas in hectares for all the farms in your well_located_farms layer.
  • Click the edit mode button again as above, and save your edits when prompted.
  • Do a query:


  • Click OK. Your results should look like this:


That's it! Those red farms are the ones satisfying your criteria. Well done!

Basic.png Try yourself...

  • Save your solution as a new layer, using the approach you learned above for doing so. The file should be saved under the usual directory, with the name solution.shp.

In conclusion

Using the GIS problem-solving approach together with QGIS vector analysis tools, you were able to solve a problem with multiple criteria quickly and easily.

What's next?

In the next lesson, we will look at Plugins, and how they can help you with your mapping tasks.

Module: Plugins

Plugins allow you to extend the functionality QGIS offers. In this module, you'll be shown how to activate and use plugins.

Lesson: Installing and Managing Plugins

To begin using plugins, you need to know how to download, install and activate them. To do this, you will learn how to use the Plugin Installer and Plugin Manager.

The goal for this lesson: To understand and use QGIS' plugin system.

Basic.png Follow along: Managing Plugins

  • To open the Plugin Manager, click on the menu item Plugins \rightarrow Manage Plugins.
  • The following dialogue will open, showing the different plugins already installed in your QGIS software. What you see may differ slightly to the image below, depending upon what plugins you have installed:


You can activate or deactivate these plugins by clicking on their corresponding check box.

The list of plugins that you can activate and deactivate only draws from the plugins that you currently have installed. To install new plugins, you need to use the Plugin Installer.

Basic.png Follow along: Installing New Plugins

  • To start the Plugin Installer, click on the menu item Plugins \rightarrow Fetch Python Plugins.

A dialogue will appear. The amount of plugins that you see here will differ, depending on your setup.

QGIS plugins are stored online in repositories. By default, only the official repositories are active, meaning that you can only access official plugins. These are usually the first plugins you want, because they have been tested thoroughly and are often included in QGIS by default.

It is possible, however, to try out more plugins than the default ones. To do this:

  • Open the Options tab on the Plugin Installer dialogue:


  • Click the Show all plugins except those marked as experimental option.

If you want to, you can click on the Show all plugins, even those marked as experimental option. Be aware that experimental plugins may not be fully tested.

  • Now go back to the Plugins tab to find the available plugins.


  • To install a plugin, simply click on it in the list and then click the Install plugin button.

In conclusion

Installing plugins in QGIS is simple.

What's next?

Next we will introduce you to some useful plugins as examples.

Lesson: Useful QGIS Plugins

Now you can install, enable and disable plugins. Let's see how this can help you in practice by looking at some examples of useful plugins.

The goal for this lesson: To familiarize yourself with the plugin interface and get acquainted with some useful plugins.

Basic.png Follow along: The OpenLayers Plugin

  • Start a new map with only the streets layer in it.
  • Using the Plugin Installer, find the plugin by entering the word Open in the Filter field.
  • Select the Google Layers plugin from the filtered list:


  • Click the Install plugin button to install.
  • When it's done, close the Plugin Installer.
  • Open the Plugin Manager.
  • Enable the new plugin:


  • Check the box beside it.
  • Now click OK to enable the plugin.

To use the plugin:

  • Open the plugin by clicking on Plugins \rightarrow Open Layers \rightarrow Settings.
  • Use the dialogue to choose a map type you want. In this example, we'll use the "Add Google Satellite Layer" type map, but you can choose any others if you want.
  • Enable "on the fly" projection and use the Google Mercator projection:


You should now have a new raster image in from Google that you can use as a backdrop, or to help you find out where you are on the map. Here is such a layer, with our own vector road layer as overlay:


Moderate.png Follow along: The OpenStreetMap Plugin

Since we're using OpenStreetMap (OSM) data in our examples, it would be instructive to know where it comes from. QGIS has a plugin that allows you to download and edit this kind of data easily.

  • First, ensure that you have the plugin installed by opening the Plugin Installer and filtering on the word street:


  • The OpenStreetMap plugin should be installed by default, but if it isn't, you can get it by clicking the Install plugin button.
  • Once it's installed, activate it via the Plugin Manager.
  • A new buttons and, if activated in View \rightarrow Panels \rightarrow OSM Feature, a new panel will be added to your interface:


Let us download data for Bandung. The plugin will download data for the area currently on your map.

  • Zoom in to the Bandung area.
  • To add data, click on the Download OSM data button:


Note: You may see a message stating that the latitude, longitude, or both extents are too large. This is because the OSM server doesn't have the capacity to continually give people data about the whole world. To prevent people trying to download too much data, there's a limit to the size of the area for which you can download data. If you get one of these error messages, zoom in to a smaller area on the map.

  • If you have an acceptable area, you can leave the other options as default and click the Download button.
  • After a while, the data will be downloaded, and will be shown in your map automatically. Here's an example:


With any of the OSM layers selected in your Layers list, the buttons in the plugin's dock panel will become active:


  • Using the plugin's own Identify feature tool (at the far left of the above buttons), click on any feature in the OSM layers to retrieve its data and see it displayed in the plugin interface. For example, clicking on the polygon near the top of the screen in our example shows it is a golf course:


  • You can create new features (point, lines, polygons) as well as edit a feature that you have identified. For example, using the plugin's Identify feature tool as before, you can click on this polygon and see that it is a forest without a name:


  • Double-click in the <new tag here> field.
  • Select a new tag (attribute) from a list. Let's choose name:


  • Double-click in the Value field:


You can now enter a name for the forest. You can save your changes to the original source data, too. This makes the changes available internationally on the OSM server.

  • Click the Upload OSM data button:


This gives you a dialogue, which you can fill in as needed.

If you have a user account at OSM, you can enter your credentials in the spaces provided and click the Upload button to save those changes.

Note that the plugin has many other functions: for example, you can also save OSM layers to a local directory, load data from saved OSM layers, and export OSM data as shapefiles.

OSM's data comes from, and is maintained by, the efforts of their users. Contributing data using this plugin allows you to help improve the quality of the OSM data you depend on.

In conclusion

There are many useful plugins available for QGIS. Using the built-in tools for installing and managing these plugins, you can find new plugins and make optimum use of them.

What's next?

Now we will look at combining some of the skills you have learnt in a practical exercise involving data from iSIKHNAS.

Module: Using QGIS in animal health

The purpose of this module is to show how QGIS can be used to assist in animal health scenarios. In order to do this, you will have needed to study, and be familiar with, the previous chapters of this manual, but in particular you need to be familiar with chapters 3 - Creating a basic map, and chapter 7 - Vector analysis.

Lesson: Putting it into practice - iSIKHNAS

In this chapter we are going to use some of what you have learned and apply it to data taken from the ISIKHNAS database.

GIS has become an essential tool in the understanding and management of animal movements and disease. It can provide valuable assistance in a range of tasks, including:

  1. monitoring animal distribution or movements
  2. describing the level and distribution of disease
  3. assessing the efficacy of control programs across space
  4. developing zones for disease control
  5. exploring spatially-linked risk factors
  6. management of animal health emergencies.

This exercise is designed to show you how you can use QGIS in a practical way, using data that you are familiar with.

The goal for this lesson:

Your supervisor has asked you to identify and extract all the cases in the Sulawesi Selatan region, where the species is a type of poultry, and the syndrome recorded is poultry mortality. S/he would like you to provide a map showing where these cases have occurred, and to create a 15 kilometre buffer around the villages in which they have occurred.

In order to do this you will have to:

  • load vector shapefile layers and create a new QGIS project
  • format the styles appropriately
  • subset a dataset spatially using Select by location
  • identify particular records in the attribute table using SQL (structured query language)
  • save records to a new shapefile
  • save layers with a projection suitable for spatial exercises
  • create a buffer zone
  • use the clip feature to create a layer including only the data required.

For the purpose of these exercises you will be using the shapefiles provided. It is possible to connect directly to the iSIKHNAS database and access the current data however this is beyond the scope of this exercise.

Basic.png Follow along: Create a new map

Open QGIS. Using the Add Vector Layer button, add the following layers from the course exercise data, from the folder ISIKHNAS:

  • Sulawesi
  • Sul_sthn_dist
  • cases_gis

Your map will now look something like this:


The colours will no doubt be different, and probably not suitable. Take the time now to change the style to use the Style tab in the Layer Properties to change the colours to those of your choice. As a refresher:

  • Right-click on the layer
  • Select Properties
  • Click on the Style tab as described above

Here you can change the formatting of the layer in many ways, including colour, fill, symbols, lines, and more.


You can save the colours you choose as styles, so you can easily apply them to other projects.

Basic.png Try yourself... Saving styles

You might want to save a particular colour to be used for your background layer, both in this project and any future mapping projects. To do this, choose the layer you would like to work with, for example Sulawesi. Open the Layer Properties.

Explore your options. As shown in the above image, there are two Change buttons.

The first Change button, with the little spanner, allows you to format items including:

  • the symbol layer type
  • the colour
  • the fill style
  • the border colour
  • the border style
  • the border width

If you only want to change the colour of the layer, click on the second Change button.

Once you are happy with your layer style, click on Save Style ...

Save your new style with a name that will make sense to you later, such as BaseCountry. It is a good idea to save all your styles in the one folder so you can easily find them again.

To use a style you have saved, click on the Load Style ... button.

We changed our colours of our layers to this:


There is a very useful website named colourbrewer: colour Advice for Maps found here <>' developed by Cynthia Brewer of Penn State. This site contains a lot of useful information about appropriate colour schemes for maps.

Save your work as a new project.

image Follow along: Selecting records

There are several ways of selecting records from layers, including:

  • Select Single Feature
  • Select Features by Rectangle
  • Select Features by Polygon
  • Select Features by Freehand
  • Select Features by Radius

This are found by clicking on the Select Features by Polygon button, and referring to the drop down menu.


This is a useful tool for selecting one or two features, or quickly drawing around an area. When we want to be more accurate, we can use the Select by Location tool.

To find the Select by Location tool, click on the menu Vector - Research Tools - Select by location:


By selecting features of one layer that intersect with another, we can create a new layer containing just the features we are interested in.

Moderate.png Follow along: Selecting by location

Now that we have our map layers loaded into our project, we would like to work specifically with Sulawesi, and in particular, the cases that have been recorded in the Sulawesi Selatan districts. Currently our map shows all the cases recorded throughout Indonesia at the time the data was downloaded.

Open the Select by Location. We want to select the features in the cases_gis file that intersect with the Sul_sthn_dist file:


Click "OK' and check your map. You should see that the cases that occur in Sulawesi Selatan are now highlighted:


Save this selection as a new layer by right-clicking on the cases_gis layer, and then clicking on Save Selection As...:


Save your new layer as Sul_sthn_cases and add it to your map. If you feel the need, format the colour.

You can now remove the cases_gis layer.

Basic.png Follow along: Inspect the data

As mentioned above, you need to extract all the cases of poultry mortality in poultry in the Sulawesi Selatan region. How would you go about doing that?

One answer lies in a layer's Attribute Table. Here you are able to see much more information about each record in the layer. The Attribute Table has been mentioned earlier, particularly in Chapters 3 and 4. Now we are going to use the information contained in the attribute table to select the records we require.

When we open the Attribute Table for the Sul_sthn_cases layer, we see several columns showing information about each record:


What information do you notice?

In this example we can see there are 1728 records in total in this layer. The attribute table has columns containing the following information:

  • gid (Geographic identification)
  • reportdate
  • caseid
  • species
  • cases
  • reporttype
  • syndrome2
  • reporter
  • desa

We can use this screen to find (for example) all the records relating to chickens by typing in chicken in the Look for box, choosing species in the drop down box and clicking on Search. Immediately, all the records with chicken recorded as the species are highlighted in the attribute table.

Note: Notice the Case sensitive option. It is best to leave this box unticked.

That way your search will return results for Chicken and chicken, and any other variations of sentence case.

However, we do not want just chickens, we want all poultry that are recorded with poultry mortality as the syndrome. To select these records, we need to use the Advanced search features.

Moderate.png Follow along: Selecting records using SQL (Simple Query Language)

The Advanced search features allow us to create more specific queries, selecting records with the particular attributes we are interested in.


Our query is asking for all the records that contain chicken or duck or local chicken as the species, and a value of "poultry mortality' in the syndrome2 table.

By testing the query, we find that we have 11 matching records:


Click OK in the window saying Found 11 matching feature(s), and click OK in the "Search query builder' window. Note that at the top of the attribute table you will now see the heading Attribute table - Sul_cases_sthn (11 matching features). Click Close on the attribute table.

Now that we have our records selected, we will use the Save selection as option that we used before, and save this layer to our map. Right-click on the Sul_sthn_cases layer, and click on Save selection as.


Name this new layer Cases_PoultryMortality and add it to your map.

By turning off the Sul_sthn_cases layer, we can now see the records in the database of poultry mortality recorded in poultry in Sulawesi Selatan.


Note: We have used the Advanced Labeling tool referred to in Section 4.2.1 Using labels to show the labels of each of the districts.

Save your project.

Moderate.png Try yourself... Selection using SQL

Using the Advanced search features in the Attribute table for the Sul_sthn_cases layer, try selecting specific records according to various combinations.

Do not be afraid to experiment. Try selecting records different combinations such as the date, village, species, syndrome etc.

In conclusion

There are several ways available for selecting data. Which method you choose will depend upon your needs.

Using SQL queries enables you to select records according to the particular attributes that are of interest to you.

What's next?

Now you have your basic map showing where the cases of interest are located. In our next lesson we will review why we are going to need to project our layers in order to develop suitable buffers.

Lesson: Projecting layers

We have created a map showing all the cases of poultry mortality in the Sulawesi Selatan region. Now we need to consider our approach to creating the required 15 kilometre buffer zone around these cases.

The goal for this lesson:

To review map projections

Basic.png Follow along: Projecting the layers

Think back to Chapter 7 where you learnt about projections, and now take a look at the layers on your map. Is their CRS (Coordinate Reference System) a Geographic Coordinate Reference System (GCS) or a Projected Coordinate System (PCS)? How can you tell?

The easiest way is to check the Coordinate box at the bottom of the map canvas. It should be showing longitude and latitude values in decimal degrees, separated by a comma e.g. 120.723,-4.971.

To find even more detail about a layer's CRS, right-click on the layer, and go to Properties, then click on the General tab you will see that the CRS is EPSG:4326 - WGS 84. Even greater detail is seen when you click on the Metadata tab.


As a general rule, if you are going to manipulate spatial data using tools from the Vector menu, your layers will need to be projected to a format where distance is expressed in measurement units such as metres.

For this exercise we will use the Universal Transverse Mercator (UTM) zone 50s (EPSG 32750).

  • Right-click on the Cases_PoultryMortality layer in the Layers list.
  • Select Save As... in the menu that appears. You will be shown the Save vector layer as... dialogue.
  • Click on the Browse button next to the Save as field.
  • Navigate to the folder you have nominated to store your exercise data and specify the name of the new layer as PoultryMortality_32750.shp.
  • Leave the Encoding unchanged.
  • Click the Browse button beneath the dropdown.
  • The CRS Selector dialogue will now appear.
  • In its Filter field, search for 32750.
  • Choose WGS 84 / UTM zone 50S from the list.
  • Click OK.

Basic.png Try yourself... Project the remaining layers

Repeat these steps for your remaining layers, adding the new, projected layers to your map. You can now remove the original, unprojected layers from your map. As we have determined that we are only using maps from the areas in Sulawesi Selatan, you no longer need your Sulawesi layer.

The option to project On the fly should be turned off.

Your map should now look something like this:


Note the Coordinate box shows the units in metres instead of degrees.

Save your project.

Lesson: Buffering

Now we have have our layers necessary to create our 15 kilometre buffer. Or do we?

The goal for this lesson:

To consider and understand point data versus polygon data, and how what effect each type will have when creating a buffer zone.

Basic.png Follow along: Point data, centroids and polygons

If you look at your map you will notice that the cases of poultry mortality occur mostly in the districts of Barru and Sinjai.

For this exercise we are going to add a new vector layer, VillagePolyBarSin_32750, which shows the boundaries of the village polygons in Barru and Sinjai.

Once you have loaded this layer, arrange the layers so the cases are on top of the village boundaries. Look closely at where the cases lie within the village polygons (you may have to zoom in closer on your map).

What do you notice?


Every case is positioned in the centre of the village boundaries. This suggests they are not the exact coordinates of where the case occurred - all we know is the case occurred somewhere in that particular village. The data is recorded at village level, and it is positioned using the centroid of the village polygon.

How will this affect our 15 kilometre buffer zone? Let's find out.

Basic.png Follow along: Buffering from the village centroid

For this buffering exercise we will use the PoultryMortality_32750 file we created. Select this layer, and go to the Vector menu. Hover over Geoprocessing Tools and select Buffer(s).


The following window will open:


Choose PoultryMortality_32750 as the input vector layer, and use a buffer distance of 15000 (remember your layer units are metres).

Click on Dissolve buffer results.

Click on Browse and name your new shapefile PoultryM15kmBuffer_32750.shp.

Add this layer to your map. The result should look something like this:


Do you see that the buffers naturally extend into the sea? We will now use the Clip function to fix this.

Basic.png Follow along: Clipping datasets

We can use one dataset to cut through another dataset, leaving us with only the information we want.

In this case, we are going to clip our new buffer layer with the DistrictsSthnSul_32750 layer that you should have created in section 16.2.2 Try yourself... Project the remaining layers.

Note: You may have named it differently, such as Sul_sth_dist_32750.

Again, we move to the Vector menu, hover over the Geoprocessing Tools, and select Clip.


Our input layer is the layer we want to change, in this case our new buffer layer. The clip layer is the layer we will use cut around our buffered layer.

Click on the Browse button, and name your new shapefile PoultryM15kmBufferClip_32750.shp.

Add it to the map.

Remove the PoultryM15kmBuffer_32750.shp layer.

Your screen should now look similar to this:


Our new layer is fitting nicely within the coastlines of South Sulawesi and your supervisor can easily see where the 15 kilometre buffers extend to.

But is this the best buffer zone for the data?

Remember the data suggests the cases are recorded in the database as being in the centre of each village - in reality they are probably taken from anywhere within the village boundary.

This means our 15 kilometre buffers are not going to be as accurate as they might be.

In the next section we will create the buffer using the village polygon layer and compare the two results.

Basic.png Try yourself... Buffering using the village polygon

Using the same skills you have learnt above to buffer and clip layers, create a 15 kilometre buffer zone around the village polygons containing cases of poultry mortality. Clip your new layer and add it to your map, naming it PoultryM15kmBufferPolyClip_32750.

Rearrange the layers, so that the buffer zone created with the village centroids is visible over the top of your new buffer zone created with the village polygons. What do you notice?


In this picture, the dark green shows the buffer zone around the village polygons (shown in the light colour). The lighter green shows the buffer zones created using the case data points.

Since we don't know exactly where each case occurred, it is a good idea to consider using the village polygons when creating a buffer zone, not the village centroids.

What's next?

It would be useful if we could estimate by looking at our map how many cases have been recorded in each village. In our next lesson we will review more styling, and how to colour areas according to particular attributes we wish to display.

Lesson: Styling to show density

[animalhealth/exercise4::doc] A good map is able to convey information quickly and clearly. For example, we can use colour to indicate the number of cases in each village of the particular syndrome we are investigating.

The goal for this lesson:

To review ways of styling our maps so the information is displayed in the clearest possible way.

Basic.png Follow along: Styling to show density

Open the PoultrySuddenDeath_32750 attribute table and have a look at the columns. What do you notice? What information can you easily display on your map?

Take a look at the cases column. It tells you the number of cases recorded in each village. We can use colour coding to display this information on our map.

To do this, open the layer properties for PoultrySuddenDeath_32750 and click on the Style tab.

Select Graduated from the pull-down rendering menu. This spreads our chosen colours from light to dark, or dark to light.

Set the Column to cases, and the Classes to 5.

The colour ramp can stay at blue for now, and the Mode can be set to Equal Interval. QGIS should immediately provide a set of five blue colours, with five equally spaced intervals. (If not, click on Classify).

Click on Apply to see how this looks on your map.

What do you notice?


Our points on the map are very small, and it is difficult to distinguish the colour variation. One way to change this is to experiment with the size of the points.

To do this, open the layer properties for PoultrySuddenDeath_32750 and click on the Style tab again. This time, click on the change button next to Symbol. Experiment with the size of the point until you think it is large enough to show the varying shades.

This is what it looks like when the size is set to 5 millimetres:


What's next?

This improves our map for showing which villages have recorded the most cases, but it would be better if we could show this using the village boundaries.

In our next lesson, we will learn how to join layers together by their location. This will enable us to create a new file that combines attributes such as the case numbers from the PoultrySuddenDeath_32750 shapefile and the village boundaries from the VillagePolyBarSin_32750 shapefile.

Lesson: Joining two layers together

There are two ways we can join layers together:

  • we can use the Join by location tool to create a new layer combining the attributes from two different layers, or,
  • we can join using a single matching attribute.

The goal for this lesson:

To use create a new shapefile using the Join by location tool

To display information from a non-spatial file on a spatial file, by joining the two using a common data field.

Moderate.png Follow along: Join attributes by location

In the last lesson we reviewed how to use colour to show the density of case records in each village however the results were not really adequate because our file containing the case records shows them on the map as point data. We would really like to colour the entire villages as shown in the file containing the village boundaries. We can't do this using the file as it is, because it does not contain the cases information. We need to join the two files using the Join attributes by location tool, located under Data Management Tools in the Vector menu.


Use the VillagePolyBarSin_32750 file as the Target vector layer, and the PoultryMortality_32750 file as the Join vector layer:

  • Click on Take the summary of the first located feature under Attribute Summary
  • Tick the Sum box underneath.

Browse to where you are going to save your file, and name it appropriately (we used PoultryMJoinLocation_32750).

Only keep the matching records. Click OK and add the new layer to your map.

Close the Join attributes by location dialogue box.

Your results should look similar to this:


Now open the Attribute table of your new layer. You can see that the new layer has the attributes of each original file, including the number of cases. We can now use this to improve our depiction of case density on the map.

Basic.png Try yourself... Style the villages to show the density of recorded cases

Using the skills from the previous lesson, amend the style to show the case density in each village. Experiment with the effect of choosing different intervals:

  • Equal Interval: Divides your data into equally-spaced groups.
  • Quantile: Uses an equation to divide values into equal-sized subsets.
  • Natural breaks (Jenks): Tries to minimise differences within classes whilst maximising the difference between classes. Standard deviation: Illustrates how values deviate from the average.
  • Pretty breaks: Breaks the values into classes that are easily understood by non-statisticians.

Explore the effect of each of these, using Apply to see the changes each makes to your map.

Lesson: Joining vectors by attribute

For this exercise, we would like to join a file from the iSIKHNAS database, with no associated spatial data, with a shapefile that does have geometric data. By doing this, we can display the data from the iSIKHNAS file on a map of Indonesia.

The goal for this lesson:

Your supervisor would like the data in a report from iSIKHNAS displayed on a map of Indonesia.

The problem you face is there isn't any spatial data associated with the data file.

To display the data for your supervisor, you are going to have to join the data file to a file that contains spatial data (such as a shapefile) and can be displayed.

Basic.png Follow along: Load the required files

Load the particular shapefile you wish to use. This could be:




In this example we are using the Provinces shapefile.

There are two ways in which we can load our table from iSIKHNAS. You already know the first one "“ loading layers using the Add vector layer button.


In this scenario, you might download the data file you need as a .csv file from the iSIKHNAS website.

Save the .csv file in a folder where you will find it again.

Upload it to QGIS using the Add vector layer option.

Remember to choose the correct file type (in this case .csv). Otherwise it may default to shapefiles, and you will not be able to choose your .csv file.


Or, you might want to load your own Excel file that you have been working with. From QGIS 1.8 onwards, you are able to load an Excel file directly into QGIS as well.

Note: QGIS 1.8 will import Excel files saved as .xls, NOT in the newer .xlsx format.

If you are using QGIS 2.0 onwards, it should be able to import an .xlsx file.

The second way is using the supplied user login details to connect directly with the database.


In this example we have used the rph_prov_week_gis_centroid table, from the iSIKHNAS training database.

We have found this by scrolling through the available tables.


Double-click on the table and it will load in QGIS.

Our example QGIS project now looks like this. Save this as a new project.


Basic.png Follow along: Compare the loaded files

Look closely at the Layers window, and the two files shown there.

What do you notice?


The layer for the provinces can be displayed in QGIS, and therefore must contain spatial data. We know this from the little polygon icon next to the file name, and the little tick box beside it.

The layer for the slaughter statistics does not contain spatial data. It is a table only and cannot be displayed. We know this from the little table icon next to the file name, and there is no tick box.

Now compare the attribute tables for rph_prov_week_gis_centroid and Provinces.

What do you notice?



Both files contain an identical field code (this is the unique code for each location).

The code field is the field we can use to join these two layers together. By creating a join, we can display the attributes from the rph_prov_week_gis_centroid file with the images from the Provinces shapefile.

Moderate.png Follow along: Joining files

Right-click on the Provinces shapefile and open the layer Properties. Click on the Join tab as shown below:


Click on the green plus sign, to open this window:


The join layer is the rph_prov_week_gis_centroid file.

The join field is the field in the rph_prov_week_gis_centroid file that we are going to use to join the two files. In this case, we are going to use the field code. This is selected from the drop down list.

The target field is code again "“ this is the field in the Provinces file that has matching data to the code field in the rph_prov_week_gis_centroid file.


The names of these fields do not necessarily have to match, but the information contained in each field must refer to the same attribute.

For example, one file might use the name code and the other file might use the name location_code. We can still join the two files as long as the data itself is identical.

In this case we are referring to the code given to each location.

Click OK.

Now open the attribute table for the Provinces shapefile again.

What can you see?


The attributes from the rph_prov_week_gis_centroid:kbd: file (gid, name, and sum) are now in the attribute table for the Provinces file. The

We can now use this to map the data from the rph_prov_week_gis_centroid file on the Provinces image.

Basic.png Try yourself... Format your new map using the styling tab

Using the skills you learnt earlier about style formatting, look for ways that will display your data in a way that is helpful.

For example, we can now format our map to show density, because we have the sum of the number of animals slaughtered in our new attribute table.


Our rph_prov_week_gis_centroid file contained summary slaughter statistics for each province.

By joining this file with the Provinces file, we are able to format the style to indicate the numbers of animals slaughtered in each province.

In conclusion

It is possible to display the information in a data file that does not contain spatial data by joining it to a file that does contain spatial data.

Both files must contain an identical data field in order to join the two files.

The headings of the two fields do not have to be the same, just the data contained in those fields.

What's next?

In our next, and final, exercise, we will investigate some of the movements data (showing livestock moving from one place to another). Here we will work through a simple and practical exercise as another example of an actual task that you may be asked to complete.

Lesson: Working with movement data

iSIKHNAS collects many types of data. One of these is movement data, showing the movement of livestock from one place to another.

The goal for this lesson:

To create a map that clearly shows livestock movements.

Your supervisor would like you to extract a dataset of poultry movements between certain dates. S/he would then like you to create a map that shows:

  • Poultry movements between 1 December 2013 and 31 December 2013
  • Format the style to clearly show density

Moderate.png Follow along: Selecting data using SQL

For this exercise, start a new project. Load the following shapefiles supplied in your data folder:

  • Indonesia_32750
  • Sulawesi_dist_32750
  • movements_32750

Use the Layer Properties to style the layers as necessary like you have done in the exercises.

Your new map should look similar to this:


Open the Attribute table for the Movements_32750 layer. You can do this by either right-clicking on the Movements_32750 layer, and selecting Open Attribute Table, or you can click on the icon in the menu bar as shown below:


Here we will select the records we want using SQL. Open the Advanced search option. You want to select all records relating to poultry, that are between 1 December 2013 and 31 December 2013.

To do this, you need the following query:

("Tanggal" >= "2013-12-01" AND "Tanggal" <= "2013-12-31') AND (("Spesies" = "broiler") OR ("Spesies" = "chicken") OR ("Spesies" = "duck") OR ("Spesies" = "pigeon"))

This query is asking to return records:

Between the two dates: ("Tanggal" >= "2013-12-01" AND "Tanggal" <= "2013-12-31")


With the following species:

(("Spesies" = "broiler') OR ("Spesies" = "chicken') OR ("Spesies" = "duck') OR ("Spesies" = "pigeon"))

If you test the query, it should return 30 records:


Close the attribute table. Your selected records should be highlighted in yellow on your map.

Right-click on the movements_32750 and choose the Save selection as option. Save your new layer with an appropriate name such as movements_poultry_32750. You can now remove the movements_32750 layer.

When you look closely, you will see that all the movements take place in Sulawesi. If you like, you can remove the layer Indonesia_32750.

In the next section we will review styling again, and show density in our movement data.

Moderate.png Follow along: Style formatting

Our movements data for is now showing on the map, but it doesn't really tell us too much about it. We can use styling to show more.

Right-click on your new movements_poultry_32750 and click on the Style tab.

As you have learnt previously, here you can style your layer to show attributes such as density. You can also:

  • colour the movement lines according to the number of animals in each movement (density)
  • increase the width of the movement lines to show the number of animals in each movement
  • layer the movement lines so thinner lines are displayed on top of the wider lines

Moderate.png Try yourself... Style formatting

Review Section - Styling to show density and Section - Style the villages to show the density of the recorded cases.

Format the movement lines using colour to show the number of animals in each movement. The column you will use is Jumlah Hew.

Once you have your individual lines, you can double-click on each one and a new window will open. Here you can edit your line for things such as width, colour, transparency:


Experiment with the width of each line until you are happy with your results.

After changing the width of each graduated line, you will then be able to order the lines so the widest lines appear underneath the thinnest ones.

Still in the Layer properties window, click on Advanced, and then Symbol levels:


This opens up a new window, where you can order your symbols:


When ordering symbols, the first symbol to be placed on the map is the one with a zero. In the image above, you can see that our widest line is a zero, and the narrowest line is a four. The result is this:


This shows our lines formatted using colour and line width to show the number of animals in each movement. The darker, thicker line shows us there were between 860 and 1000 birds moved in this particular movement.

What's next?

Our final lesson is to show how to load another type of data into QGIS. Sometimes you will receive data as a spreadsheet, or you might download it from a source such as a database as a CSV file. We will now show you how to load this type of data into QGIS.

Lesson: Loading point data

We have worked with data in the form of shapefiles, raster files, and directly from databases. Sometimes your data will be in an Excel spreadsheet, with longitude and latitude. It is important that you know how to load data when it is in this format.

The goal for this lesson:

To load and plot data from a spreadsheet.

Basic.png Follow along: Loading a Delimited Text File

For this exercise, you will begin a new project.

We have worked with data in the form of shapefiles, raster files, and directly from databases. Often you might receive data in the form of a spreadsheet, so it is important to know how to load this data into QGIS.

Data is supplied in this way is often in a CSV file, which is a delimited text file. To load these types of files, we will use the "Add Delimited Text Layer" plugin:


Click on this button, and the following dialogue will open:


Browse to the course exercise data, and load PointData.csv from the folder ISIKHNAS. This is just randomly generated point data to use for this exercise.

The plugin does a very good job of reviewing the information contained in the file, but you will need to give it some guidance. In this file, the delimiter is a comma, so we need to select "Comma" as the delimiter.

Your dialogue box now looks like this:


Click on the OK button. You will now be asked to specify the CRS. This should make you think about what format the data was collected in. For now we will select WGS 84 EPSG:4326. Click OK.

You should have a layer similar to the following image:


This shape should look familiar - load the shapefile Sul_sthn_dist, and rearrange the layers so the point data is the top layer.

You should now see something like this:


In conclusion

This chapter has been designed to show you how to use QGIS in a practical and useful way, using real data obtained from the iSIKHNAS database. The exercises have been developed to show examples of actual tasks you may be asked to carry out by your supervisor.

It is only a small example of what you can do using the QGIS software. If you are interested, do not be afraid to explore the software. Use the internet to search for new ways to create particular maps, or investigate different ways of doing things.

Answer Sheet

Results for Adding Your First Layer

Basic.png Preparation

You should see a lot of lines, symbolizing roads. All these lines are in the vector layer that you just loaded to create a basic map.

Results for An Overview of the Interface

Basic.png Overview (Part 1)

Refer back to the image showing the interface layout and check that you remember the names and functions of the screen elements.

Basic.png Overview (Part 2)

  1. Save as
  2. Zoom to layer
  3. Help
  4. Rendering on/off
  5. Measure line

Results for Working with Vector Data

Basic.png Shapefiles

There should be three layers on your map:

  • waterways
  • places and
  • streets.

Basic.png Databases

All the vector layers should be loaded into the map. It probably won't look nice yet:


(We'll fix the ugly colours later.)

Results for Symbology

Basic.png colours

  • Verify that the colours are changing as you expect them to change.
  • It is enough to change only the waterways layer for now. An example is below, but may look different depending on the colour you chose.


Note: If you want to work on only one layer at a time and don't want the other layers to distract you, you can hide a layer by clicking in the check box next to its name in the Layers list. If the box is blank, then the layer is hidden. We have hidden some of the layers in this picture.

Basic.png Symbol Structure

Seen together, your forests, waterways, and bandung_districts layers should look more or less like this:


If you are a Beginner-level user, you may stop here.

  • Use the method above to change the colours and styles for all the remaining layers.
  • Try using natural colours for the objects. For example, a road should not be red or blue, but can be gray or black.
  • Also feel free to experiment with different Fill Style and Border Style settings for the polygons.

Moderate.png Symbol Layers

  • Customize your layers as you like, but remember that it has to be easy to tell different layers apart on the map.

Here's an example:


Moderate.png Symbol Levels

To make the required symbol, you need at least three symbol layers:


The lowest symbol layer is a broad, solid yellow line. On top of it there is a slightly thinner solid dark gray or black line. The symbol layer on top is a thin white dashed line.

  • If your symbol layers resemble the above but you're not getting the result you want, check that your symbol levels look something like this:


  • Now your symbol should look like this:


  • Which, on the map, gives you this kind of effect:


Hard.png Symbol Levels

  • Adjust your symbol levels to these values:


  • There are a lot of symbols with this style
  • Experiment with different values to get different results.
  • Open your original map again before continuing with the next exercise.

Results for Attribute Data

Basic.png Attribute Data

The NAME field is the most useful to show as labels. This is because all its values are unique for every object, and it contains no "null" values (i.e., fields with no value).

Results for The Label Tool

Moderate.png Label Customization (Part 1)

Your map should look like this:


Moderate.png Label Customization (Part 2)

One possible solution has this final product:


To arrive at this result:

  • Use the font type Arial of size 10 and a Label distance of 1,5 mm.

  • In addition, this example uses the Wrap label on character option:</p>


  • Enter a space in this field and click Apply to achieve the same effect.

Hard.png Using Data Defined Settings

  • Still in edit mode, set the FONT_SIZE values to whatever you prefer. The example uses 14 for universities, 12 for hospitals, and 10 for the remaining places.
  • Remember to save changes and exit edit mode.
  • In Data defined settings, do this:


Your results, if using the above values, should be this:


Results for Classification

Moderate.png Refine the Classification

  • Use the same method as in the first exercise of the lesson to get rid of the lines:


The settings you used might not be the same, but with the values Classes = 7 and Mode = Natural Breaks (Jenks) (and using the same colours, of course), the map will look like this:


Results for Vector Analysis

Basic.png Find Important Roads

Your layer should now have these roads:


  • Save this new layer (the same way you did before) under exercise_data/residential_development/, as important_roads.shp.
  • Once the new layer has been added to your map, remove the old layer.
  • If for some reason it gives you an error message saying that it can't add the layer to the map (this can happen), remember that you can add the layer yourself by using the Add Vector Layer button as you did before.

Basic.png Distance from High Schools

  • Your buffer dialogue should look like this:


The Buffer distance is 10000 meters (i.e., 10 kilometers).

  • The Segments to approximate value is set to 20. This is optional, but it's recommended, because it makes the output buffers look smoother.

Compare this:


To this:


The red circle is the buffer with Segments to approximate set to 20; the gray circle on top of it is the buffer with Segments to approximate set to 5.