QGISDay14Aug2010

...back to Africa_Local_Chapter

Introduction to QGIS

= What? =

Our third OSGeo local chapter meet up! We will show you some cool stuff and start to get people familiar with the brilliant FOSS GeoSpatial products out there, specifically QGIS on this occasion! (FOSS = Free and Open Source Software)

We'll go through installing QGIS and getting it to a point where you can have fun (and get your job done) with it.

You will learn how to drive QGIS and see how QGIS can be used to perform the most common GIS operations, including - making a map (cartography) - overlay analysis - spatial queries - data capture (mapping) and editing - working with different data sources - applying QGIS in your work environment (education, government, etc.) - how QGIS can integrate with other GIS software. - basic spatial analysis (vector and raster)

We will also touch on using PostGIS, GRASS and web services.

It will be a big group of varied experience and from every sector. You'll see how to use QGIS through the whole GIS supply chain and have a go at it yourself. You will also meet a great community and have some fun to boot!

The format will include some presentations, demos and case studies along with some step-by-step hands-on work.

= How Much? =

R150 to cover costs, lunch and refreshments. That and an open mind are all you need to bring.

Cost includes: lunch, teas, CD/DVD. Any profit goes towards equipping the school's GIS lab. Presenters' time is voluntary.

Pay by EFT before 6 August into: Bridge House School Nedbank Account no: 1470067196 Branch code: 198765 Reference: GIS - your name

= Where? =

Venue: Bridge House School, next to Graham Beck Estate, Franschhoek
 * http://www.openstreetmap.org/?lat=-33.87900&lon=19.03053&zoom=15
 * http://tracks4africa.co.za/listings/item/w135795/

NB: We'll be in the Theatre.

If you want to share transport, one participant has set up this service to help (thanks David).

= When? =


 * Saturday August 14 2010
 * 08h15 registration for prompt 09h00 start, till 16h00 (or beyond)
 * includes lunch and refreshments

= Who =

Your friendly presenters for the day will be:


 * Horst Düster Horst is a special guest from the Swiss Canton of Solothurn, where all government systems are 100% FOSS.
 * Tim Sutton (tim at linfiniti.com) - QGIS hacker and FOSS GIS junkie extraordinaire. Tim eats Weetbix for breakfast because it sounds like Linux. He once rewrote Nkosi Sikelela in C++ because he was feeling patriotic. Tim is on the QGIS project steering committee.
 * Gavin Fleming (gavinjfleming at gmail dot com) - He enjoys his daily FOSS4G fix. He's a freelance 'geoinformation scientist' currently at SAEON and he loves to see cutting edge and useful geospatial applications emerging, especially when they're based on FOSS. Gavin chaired FOSS4G 2008 and leads the OSGeo local chapter/ GISSA FOSS SIG.

= RSVP = To confirm, send gavinjfleming at gmail dot com proof of payment and any dietary preference.

= Programme and notes =


 * Be there in time for a 8h15 registration, 9h00 start
 * Please don't bring your own computer. We'll have 60 networked PCs with a massive screen and good AV.
 * It doesn't matter what GIS experience you have.
 * The programme is subject to change and participant input right to the last minute!

Introduction
9h00-10h00

Introduction to FOSS GIS - Horst
Horst will give a presentation and demonstrations on how FOSS GIS is used in the real world.

Driving QGIS
10h20-11h20

First tour of the User Interface - ______
Before we set off into the QGIS journey for today, lets get a bit familiar with the vehicle - the GUI or Graphical User Interface!

The key principle is simplicity - standard GIS functionality should be easy to find and obvious to use. More complex functionality is layered onto QGIS as needed via a plugin or extension mechanism

The QGIS GUI is divided into six areas:

1.Menu Bar

2.Tool Bar

3.Map Legend

4.Map View

5.Map Overview

6.Status Bar

1.	Menu Bar

The menu bar provides access to various QGIS features using a standard hierarchical menu. The top-level menus and a summary of some of the menu options are listed below, together with the icons of the corresponding tools as they appear on the toolbar, as well as keyboard shortcuts. Although most menu options have a corresponding tool and vice-versa, the menus are not organized quite like the toolbars. The toolbar containing the tool is listed after each menu option as a checkbox entry.

2.	Toolbars

The toolbars provide access to most of the same functions as the menus, plus additional tools for interacting with the map. Each toolbar item has popup help available. Hold your mouse over the item and a short description of the tool’s purpose will be displayed.

Every menubar can be moved around according to your needs. Additionally every menubar can be switched off using your right mouse button context menu holding the mouse over the toolbars.

Tip: RESTORING  TOOLBARS If you have accidentally hidden all your toolbars, you can get them back by choosing menu option Settings->Toolbars

3.	Map Legend

The map legend area is used to set the visibility and ordering of layers. Layers listed nearer the top of the legend are drawn over layers listed lower down in the legend. The checkbox in each legend entry can be used to show or hide the layer.

Layers can be grouped in the legend window by adding a layer group and dragging layers into the group. To do so, move the mouse pointer to the legend window, right click, choose Add group. A new folder appears. Now drag the layers onto to the folder symbol. It is then possible to toggle the visibility of all the layers in the group with one click. To bring layers out of a group, move the mouse pointer to the layer symbol, right click, and choose Make to toplevel item. To give the folder a new name, choose Rename in the right click menu of the group.

The content of the right mouse button context menu depends on whether the loaded legend item you hold your mouse over is a raster or a vector layer. For GRASS vector layers the toggle editing is not available.

4.	Map View

This is the ’business end’ of QGIS - maps are displayed in this area! The map displayed in this window will depend on the vector and raster layers you have chosen to load (see sections that follow for more information on how to load layers). The map view can be panned (shifting the focus of the map display to another region) and zoomed in and out. Various other operations can be performed on the map as described in the toolbar description above. The map view and the legend are tightly bound to each other - the maps in view reflect changes you make in the legend area.

Tip Zooming the map with the mouse wheel: You can use the mouse wheel to zoom in and out on the map. Place the mouse cursor inside the map area and roll the wheel forward (away from you) to zoom in and backwards (towards you) to zoom out. The mouse cursor position is the center where the zoom occurs. You can customize the behavior of the mouse wheel zoom using the Map tools tab under the Settings > Options menu.

Tip Panning the map with the arrow keys and space bar: You can use the arrow keys to pan in the map. Place the mouse cursor inside the map area and click on the right arrow key to pan East, left arrow key to pan West, up arrow key to pan North and down arrow key to pan South. You can also pan the map using the space bar: just move the mouse while holding down space bar.

5.	Map Overview

The map overview area provides a full extent view of layers added to it. Within the view is a rectangle showing the current map extent. This allows you to quickly determine which area of the map you are currently viewing.


 * Add a single layer to the overview by right-clicking on it in the legend and select x Show in overview . You can also add layers to, or remove all layers from the overview using the Overview tools on the toolbar.

If you click and drag the red rectangle in the overview that shows your current extent, the main map view will update accordingly.

6	Status Bar

The status bar shows you your current position in map coordinates (e.g. meters or decimal degrees) as the mouse pointer is moved across the map view. To the left of the coordinate display in the status bar is a small button that will toggle between showing coordinate position or the view extents of the map view as you pan and zoom in and out.

A progress bar in the status bar shows progress of rendering as each layer is drawn to the map view. In some cases, such as the gathering of statistics in raster layers, the progress bar will be used to show the status of lengthy operations.

If a new plugin or a plugin update is available, you will see a message in the status bar. On the right side of the status bar is a small checkbox which can be used to temporarily prevent layers being drawn on the map view.

At the far right of the status bar is a projector icon. Clicking on this opens the projection properties for the current project.

Making your first project - ___
Often the first thing you want to do in your GIS is pull in the layers you are interested in, symbolise them, zoom to the correct position and then save the map that results as a project (similar to a .apr or a .mxd file). This is all pretty easy in QGIS, as you might expect. So the steps we will do are:
 * Create New Project
 * Add Vector Layer
 * Add Raster Layer
 * Add Database Layer
 * Perform simple symbology change
 * Set up some project properties
 * Zoom in to an area of interest
 * Add a north arrow and a scalebar
 * Save the project
 * Close and reopen it

Advanced symbolisation - the renderer types, labelling and map actions - ____
Make it the way you want it to be!

Before we look at symbolisation, lets get to know the data a bit better. Right-click on a layer and select Properties. This is called the Layer Properties dialog. Then click on the Metadata tab.

The Metadata tab contains information about the layer, including specifics about the type and location, number of features, feature type, and the editing capabilities. The Layer Spatial Reference System tab provides projection information, and the Attribute field tab lists fields and their data types for a vector layer. This is a quick way to get information about the layer.

Symbolisation introduction

To make your map look the way you want it, double-click on a layer in the legend or right-click on the layer and select Properties from the popup menu. Then go to the Symbolisation tab.

For a vector layer you will probably see at least the following options: Outline style - pen-style for your outline of your feature. you can also set this to ’no pen’. Outline color - color of the ouline of your feature Outline width - width of your features Fill color - fill-color of your features. Fill style - Style for filling.

Click on the “Fill color” selector, and select a different colour from the pallette that becomes available. Then click Apply, and have a look at how your map has changed. Then click on the “Outline color” and then the “Fill style” selector, change the option and click Apply or OK to see the result.

Setting symbolisation options – Vector map layers

Select the Symbology tab (along the top), go to the “Legend type” choice box and and have a look at the options. You can choose to draw a vector in a number of ways, as a: Single symbol (the default) – all objects in a layer are drawn with the same symbol. Graduated symbol – objects within the layer are displayed with different symbols classified by the values of a particular field. Continuous colour. Unique value.

Now select Graduated symbol, and set the Classification field.

Notice that you can set how to group the symbols, and how many groups to use. If you want to set the options manually, then use Empty.

Now you try. Experiment with different numbers of classes and make it look just right! Ask one of the presenters for advice if the result is not as you expected.

Also try the “Continuous colour” and “Unique Value” options out. Remember that you can save your settings to a file with the “Save Style” button. This means that when you start another project, you can load that same style again for a layer.

You can also “Save as Default”, so that objects are given the style you have chosen automatically when they are loaded.

If you want to display many polygon layers at the same time, the Transparency slider (at the top right hand of the Symbology tab) is useful.

More symbolisation options: Labelling vector layers


 * Open the Layer Properties dialog.


 * Click on the Labels tab.


 * Check the Display labels checkbox to enable labeling.
 * Choose the field to label with.  You can enter a default for features that have no name.
 * Click Apply.

Now we have labels. How do they look? They are probably too big and poorly placed in relation to

the marker symbol for the lakes.


 * Select the Font entry and use the Font and Color buttons to set the font and color. You can

also change the angle and the placement of the text-label.

To change the position of the text relative to the feature:

1. Click on the Font entry.

2. Change the placement by selecting one of the radio buttons in the Placement group. To fix our

labels, choose the ⊙ Right radio button.

3. the Font size units allows you to select between ⊙ Points or ⊙ Map units.

4.Click Apply to see your changes without closing the dialog.

Things are looking better, but the labels are still too close to the marker. To fix this we can use the

options on the Position entry. Here we can add offsets for the X and Y directions. Adding an X

offset of 5 will move our labels off the marker and make them more readable. Of course if your marker symbol or font is larger, more of an offset will be required.

The last adjustment we’ll make is to buffer the labels. This just means putting a backdrop around

them to make them stand out better. To buffer the lakes labels:

1. Click the Buffer  tab.

2. Click the x Buffer Labels? checkbox to enable buffering.

3. Choose a size for the buffer using the spin box.

4. Choose a color by clicking on Color and choosing your favorite from the color selector. You

can also set some transparency for the buffer if you prefer.

5. Click Apply to see if you like the changes.

If you aren’t happy with the results, tweak the settings and then test again by clicking Apply.

A buffer of 1 points seems to give a good result. Notice you can also specify the buffer size in map units if that works out better for you.

The remaining entries inside the Label allow you to set all the attributes stored in the layer. The entries beginning with Data defined parameters for the labels using fields in the layer.

Note that the Label tab provides a preview-box where your selected label is shown.

Actions Tab

QGIS provides the ability to perform an action based on the attributes of a feature. This can be used to perform any number of actions, for example, running a program with arguments built from the attributes of a feature or passing parameters to a web reporting tool.

Actions are useful when you frequently want to run an external application or view a web page based on one or more values in your vector layer. An example is performing a search based on an attribute value.

Symbolisation options – Raster map layers

To view and set the properties for a raster layer, double click on the layer name in the map legend or right click on the layer name and choose Properties from the context menu. There are several tabs on the dialog:

• Symbology

• Transparency

• Colormap

• General

• Metadata

• Pyramids

• Histogram

Symbology Tab QGIS can render raster layers in two different ways :

• Single band - one band of the image will be rendered as gray or in pseudocolors.

• Three band color - three bands from the image will be rendered, each band representing the red, green or blue component that will be used to create a color image.

Within both render types you can invert the color output using the x Invert color map checkbox.

Single Band Rendering

This selection offers you two possibilites to choose. At first you can select which band you like to use for rendering (if the dataset has more than one band).

The second option offers a selection of available colortables for rendering. The following settings are available through the dropdownbox color map. Grayscale is the default setting. Also available are: • Pseudocolor

• Freak Out

• Colormap

When selecting the entry color map Colormap, the tab Colormap becomes available.

Colormap Tab

Three ways of color interpolation are available:

• Discrete

• Linear

• Exact

The button Add Entry adds a color to the individual color-table. Double-Clicking on the value-

column lets you inserting a specific value. Double clicking on the color-column opens the dialog

Select color where you can select a color to apply on that value.

Alternatively you can click on the button table from the band (if it has any).

The block Generate new color map allows you to create newly categorized colormaps. You only need to select the number of classes you need and press the button Classify. Currently only one Classification mode, Equal Interval, is supported.

Raster symbolisation: Histogram Tab The Histogram    tab allows you to view the distribution of the bands or colors in your raster. You must first generate the raster statistics by clicking the Refresh button. You can choose which bands to display by selecting them in the list box at the bottom left of the tab. Two different chart types are allowed:

• Bar chart

• Line graph

You can define the number of chart columns to use and decide whether you want to allow approximation or display x out of range values Once you view the histogram, you’ll notice that the band statistics have been populated on the metadata tab.

Projection basics - ____

 * Note:** I think we should leave out projections for the sake of this course. We provide all data in the same CRS and everything ready to run.

To get by in GIS you have to get to grips with Projections, even if you don't understand them completely. Layers don't overlay properly or are not even in the same place, or you need data in a specific coordinate system for a certain cartographic effect. Or if you are doing analysis, you need your data in a planar 'real-world' coordinate system in units such as metres (you can't work out an area in 'square degrees').


 * What projection settings are important?
 * We'll look at the projection properties of some layers in your project
 * and of QGIS generally: Edit>Options>CRS and Edit>Custom CRS
 * and of your project: File>Project properties>Coordinate Reference System (or click the 'projector' icon in the bottom right corner)

We'll actually project a layer (change its CRS). We'll do this by doing a 'save as shapefile' to the layer. Then we'll bring it back in and see how QGIS can 'project on the fly' to draw it with other layers that are in different projections.

Data capture and manipulation
11h40-12h40

Spatial analysis
13h00-14h00

Map production
14h30-15h30 You've been putting together a nice project and now you need to output a proper map. This is one area where FOSS GIS doesn't meet the expectations of those raised on proprietary GIS, but it's improving all the time.

In QGIS there are a few options

Go to Plugin manager in tools and enable the 'Quickprint' plugin.
 * Quick and easy

Click on the Quick Print logo which is a pdf symbol.

Fill in the details and you project view will be saved as a pdf.


 * Export an image

Goto File>Save as Image. You can choose to save a png or jpg of your project view.


 * Use the Print Composer

Goto File>Print Composer. This is where you can add titles, legends, scale bars, etc.

If you want a graticule or north arrow, first add these in the project using a plugin.

Then use the print composer to add items to a 'canvas', after which you can change their properties until your map's ready to plot.

Q&A, more show and tell, advanced topics, etc
15h45-17h00

Audience Selections
Tell us what else you'd like to try.

Possible Extras

 * Advanced spatial analysis without GRASS: Carson Farmer's plugins with R, etc - Gavin
 * Introduction to the Python console
 * The Python API
 * Show off session: Here we can do some whizz bang demo stuff that we don't have time to do in workshop format but that will give you some hints as to what else can be achieved. e.g. Terrain modelling and drapes.

General
Questions and answers. Resources. Possibly some in-depth examples based on frequent questions. What would you like to see at future workshops?

What you can do next
Install QGIS at home or work on Windows, Mac or Linux and start playing.

Read the manual.

Check out these free QGIS tutorials and courses: http://www.osgeo.org/educational_content?filter0=&filter1=qgis&filter2[]=English&filter3=

Join the QGIS community

Your assessment of the workshop
Tell us what you thought!

Where to get free spatial data?
Surveys and Mapping, Demarcation Board, OpenStreetMap, GPS, etc. Check out South_African_Geodata

END

QGIS plugins - Graeme

 * Activating Core plugins - This involves switching on some in-built plugins (Mapserver Export, GRASS, Delimited Text, for example)
 * Accessing the Python plugins - This process involves finding plugins in a repository and fetching them, then activating them

Web GIS WMS and WFS clients
Each of you should have an internet map server available on your local machine - obviously in a non-tutorial session you would be fetching data from a remote server...

We will access the Web Map and Web Feature Services provided and render them in QGIS.

A tour of some popular plugins
We will go through some of the functionality made available by the plugins now.


 * ftools provides functionality for vector-based tasks
 * topocolour
 * table manager provides the ability to edit shapefile attributes
 * mapserver export provides a basic MapServer mapfile export capability
 * GRASS (Brendon to dig into this shortly!) provides access to GRASS data and functionality through the less intimidating QGIS interface.
 * Delimited Text File allows delimited text files with spatial data to be imported into QGIS, for example, csv files

GRASS Analysis in QGIS- Brendon
GRASS is a sophisticated standalone GIS package which can also be accessed through QGIS. It installs with QGIS by default. If you don't see a toolbar with grass stalk icons, go to:

View->Toolbars

and check that the GRASS toolbar is has a tick against it. This will place the new toolbar on your QGIS interface.

If you can't see the GRASS toolbar listed there then you may need to add it from the plugin manager:

Plugins->Manage plugins->GRASS


 * Click on the first icon (the folder with a grass stalk) to open the prepared GRASS mapset, which is a collection of maps.

There are three entries needed in the box that opens up:

Gisdbase Location Mapset

These should be set to: home/tim/Grassdata training_jhb analysis


 * Then click OK to open the mapset.

Ask for help from one of the presenters if making these choices is confusing for any reason.

Once this is done, you may use the icons with the '+' symbol to add vector and raster maps from the GRASS database. You may use the QGIS context-sensitive menu (right-click) to remove layers if you do not want to see them.


 * Now open the prepared QGIS project analysis.qgs to see many of the map layers available in GRASS. We are going to use the GRASS toolbox to find answers to some questions that GIS can help us with.


 * Click on the tools icon (with the hammer and spanner) on the GRASS toolbar to open the GRASS tools window.

It has three tabs at the top:

Modules Tree, which has a list of GRASS modules grouped according to their function, rather like a Windows Explorer view of directories.

Modules List, which has a long list of modules. Type the beginning of a modules name in the box at the bottom to find it rapidly.

Browser, which shows you the GRASS map layers grouped into raster and vector groups.

information about the layer in the pane on the right. Try this with raster and vector layers, and notice that the information given is different for the two types.
 * If you pick a map layer in the pane on the left, you will see descriptive

You can leave the GRASS Tools window open while you are working with QGIS.

Why is it so noisy here?

At the end of a long day, you want to put your feet up and relax. But the noise from the freeway just never stops! How many houses in the area are close enough to a major road to be badly affected by noise?

The noise from the freeway will travel further than the noise from a suburban road. Luckily, we already have separated the freeway from the main roads and others.


 * To start the analysis, go to the modules tree and select the module Buffer, under:

Vector -> Spatial analysis


 * Another tab will open to allow you to run the Buffer module.


 * Select the map layer freeway as input.


 * Enter Buffer distance as 1000.


 * Enter name of output as freeway_buffer

Repeat for main_roads, with a distance of 200. Make the output name main_roads_buffer.


 * Then use v.patch to merge the two map layers. Do not check either of the boxes at the top of the dialog.

The progress bar at the bottom will show you how much longer you have to wait. When it is finished, click on View output to show the result in QGIS.

See how the buffers are wider around the freeway than around the main roads.

Tip: You can close the tab for the module using the Close button next to View output.

Now we want to see how many houses are affected. We have the erven outlines rather than houses, but it will be a good approximation.


 * Click on the Modules List tab, and type "v.select" at the bottom. The v.select.overlap module should appear at the top.  Click on the module name to open it.


 * Select Erven as the first input map layer.


 * Select Roads_buffer as the second input map layer.


 * Enter Erven_noise as the output map layer.

This will show you all erven overlapping the noise buffer that we created.
 * Click on Run, and View output.


 * Open the attribute table and scroll down to the bottom to see how many houses are affected.

You might want to use the Group option in the Layer Manager after doing an analysis, so that you can keep the results together. Move the group to the bottom of the Layer Manager when you are finished with it.

I can see you!

The way noise travels depends on a lot of things apart from distance. One of these is changes in height. We are going to generate an elevation surface (raster) to help us in our work.

Raster layers need to have their extent and grid size defined before we start.


 * Click on the Modules List tab, and type "g.region.multiple.vector". Enter one vector layer, v_5m_contours.
 * Now open the Modules Tree, and start the GRASS shell at the top of the list.
 * Enter g.region res=25 to set the grid resolution to 25m.
 * Close the shell.

Now we can start the real work:


 * Click on the Modules List tab, and type "v.surf.rst". Open the module.
 * Select the layer v_5m_contours as the input map layer.
 * Enter elevation as the output map surface.
 * Click Run. This process may take a little while.
 * Add the elevation surface to your display.

You may want to change the way the elevation surface displays using the Symbology options.

Now that we have an elevation surface, we can derive a lot of other information. First we will make it look better though.


 * Click on the Modules List tab, and type r.slope.
 * Choose the r.slope.aspect.aspect module.
 * Enter the name of the output map as aspect.
 * Run and add the layer.

Set this layer to about 50% transparency for a pleasing effect.

A new 32 storey shopping mall and conference centre is being proposed for development. The residents are upset that it will dominate the skyline. The architect says that it will be "bold and pleasing". How can we tell how visible it is going to be?


 * Select the r.los module.
 * Enter the coordinates of the proposed mall:
 * Enter the height as 165.
 * Enter 25000 as the maximum distance.
 * Enter elev_shade165 as the output surface name.
 * Run and view the surface to see where the development will be visible from.

Now you try - change the height of the building to what you feel is reasonable, and see what difference it makes.

Finding a home


 * Select the v.extract.where module.


 * Select land_use as the input map layer.


 * Enter landuse like Park OR landuse like Botanical Garden OR Bird sanctuary


 * Enter open_space as the output map layer name.


 * Run and view the output.

You have extracted the open areas suitable for children from the land use layer.

Now buffer these to a distance of 3km using v.buffer.

Then use the v.to.rast.constant module to convert this vector layer to a raster surface r_open_space.

West to north-west facing areas will suit our young family. A raster "mask" needs to be set up to include only suitable aspects. GRASS recognises the raster named MASK for this.


 * Enter the expression:

r.mapcalc 'MASK=(((relief@Analysis<315)&&(relief@Analysis>=270)))'

If you are feeling adventurous you can use the visual mapcalc interface to set up the expression instead.


 * Now use the simple mapcalculator r.mapcalculator. Enter open_space as the first layer (A) and aspect as the second layer (B).


 * Enter the formula A*B.


 * Run and display the output.

These are the places where are young family should look first to be happy in their new home!

END SECTION TO DELETE