Difference between revisions of "AfricaEvents27June2009"

From OSGeo
Jump to navigation Jump to search
Line 50: Line 50:
 
== Intro to the QGIS project - Tim ==
 
== Intro to the QGIS project - Tim ==
  
== First tour of the User Interface - Brendon ==
+
== First tour of the User Interface - Graeme ==
 +
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
 +
 
 +
== Making your first project - Graeme ==
 +
 
 +
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
 +
* Save the project
 +
* Close and reopen it
  
 
The QGIS GUI is divided into six areas:
 
The QGIS GUI is divided into six areas:
Line 128: Line 145:
 
Loading and viewing data - common data formats, symbolisation.  Tips and tricks to enhance image display.
 
Loading and viewing data - common data formats, symbolisation.  Tips and tricks to enhance image display.
  
== Making your first project - Graeme ==
+
= Tea =
 
 
- adding layers and saving a project
 
 
 
* Tea
 
  
 
== Map Production - Gavin ==
 
== Map Production - Gavin ==
Line 140: Line 153:
 
==Projection basics - Gavin==
 
==Projection basics - Gavin==
  
* Lunch  
+
= Lunch =
  
 
==QGIS plugins - Graeme==
 
==QGIS plugins - Graeme==

Revision as of 12:31, 26 June 2009

...back to Africa_Local_Chapter

Introduction to QGIS

What?

Our second OSGeo local chapter meet up! We will chew the cud, show you some cool stuff and start to get people familiar with the brilliant FOSS GeoSpatial products out there, specifically QGIS on this occasion!

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

How Much?

There will be a door charge of R250 to cover costs, lunch and refreshments. That and an open mind are all you need to bring.

Where?

St Davids Marist Inanda College
36 Rivonia Rd
Inanda
Sandton

Map and Directions

NB: We'll be in the Prep School computer lab.

When?

  • Saturday June 27th 2009
  • 08h30 to 15h30
  • includes lunch and refreshments

Who

Your friendly presenters for the day will be:

  • 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.
  • Graeme McFerren - (graeme.mcferren at gmail.com) - GIS researcher and FOSS4G user. Mmm, aspire to be like Tim then.
  • Gavin Fleming (gavinjfleming at gmail dot com) - I enjoy my daily FOSS4G fix. I'm a 'geoinformation scientist' at Mintek and love to see cutting edge and useful geospatial applications emerging, especially when they're based on FOSS.
  • Brendon Wolff-Piggott - (brendon at integratedgeodata.co.za) - Water resources consultant and FOSS GIS enthusiast. I wish there were more hours in the day to keep up with FOSS4G!

RSVP

Let gavinjfleming at gmail dot com know if you're coming as numbers are limited.

Programme and notes

  • Be there in time for a 8h30 start
  • Computers are provided. All you need to bring is R250!
  • It doesn't matter what level you are.
  • The programme is subject to change and participant input right to the last minute!

Intro to the QGIS project - Tim

First tour of the User Interface - Graeme

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

Making your first project - Graeme

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
  • Save the project
  • Close and reopen it

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.

Advanced symbolisation - the renderer types, labelling and map actions - Brendon

Loading and viewing data - common data formats, symbolisation. Tips and tricks to enhance image display.

Tea

Map Production - Gavin

Data capture - editing local and PostGIS datasources - Tim

Projection basics - Gavin

Lunch

QGIS plugins - Graeme

QGIS and Web GIS WMS and WFS clients - Graeme

Advanced analysis with QGIS

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.

  • If you pick a map layer in the pane on the left, you will see descriptive

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.

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 distances entered against types of road in the Roads map layer.

  • Open the attribute table and have a look.
  • 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 Roads as input.

...... go to Linux for other detail: select attrib for Buffer

  • Enter Roads_buffer as the name of the output layer.
  • Then press Run.

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.
  • Click on Run, and View output.

This will show you all erven overlapping the noise buffer that we created.

  • 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!

Audience Selections

Tell us what else you'd like to try.

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. What you can do next. Resources. Possibly some in-depth examples based on frequent questions. What would you like to see at future workshops?

Possible Extras

  • advanced spatial analysis without GRASS: Carson Farmer's plugins with R, etc - Gavin
  • Introduction to the Python console
  • The Python API

Your assessment of the workshop

Tell us what you thought!

PS: Where to get free spatial data?

Surveys and Mapping, Demarcation Board, OpenStreetMap, GPS, etc. Check out South_African_Geodata