4. CHAPTER
ONE
INTRODUCTION
Quantum GIS (QGIS) is a user friendly Desktop GIS client which lets you visualize, manage, edit, analyse data and
compose printable maps.
This workshop is based on OSGeo-Live 5.0 (http://live.osgeo.org), a bootable DVD, USB thumb drive or Virtual
Machine.
1.1 Documentation
To learn more about QGIS, a starting point is the Documentation page (http://www.qgis.org/en/documentation.html)
on the QGIS homepage.
OSGeo-Live contains a A Gentle Introduction to GIS and the QGIS User Guide.
1.2 Edit QGIS project
1. Click Geospatial → Desktop GIS → Quantum GIS
2. Choose File → Open Project... from the menu bar
3. Select QGIS-NaturalEarth-Example.qgs and press Open
• You should see a world map.
4. Check 10m_populated_places_simple in the Layers tree
• Populated places are now displayed:
5. Double click 10m_rivers_lake_centerlines in the Layers tree
2
5. QGIS Workshop Documentation, Release 1.0
6. Change the color in Outline Options to a different blue tone
7. Press OK
• Rivers are now rendered in a new color
1.3 Create a new QGIS project
1. Choose File → New Project
2. Click Layer → Add Vector Layer...
3. Browse to dataset /home/user/data/natural_earth/10m_admin_0_countries.shp
4. Press Open
• You should see all world countries
1.3. Create a new QGIS project 3
6. CHAPTER
TWO
NEW FEATURES
There are many new features to explore. This chapter gives you a few starting points for new features in QGIS 1.6 and
1.7.
2.1 Menus/Tools
• Selection Tool
• PG Connection: Buttons
• WMS Layer order
• Project Properties
• Layer Save as
• Settings / Options: CRS
• Settings / Snapping Options
2.2 Raster provider
• On-the-fly reprojection
4
7. CHAPTER
THREE
RASTER CALCULATOR
3.1 Using the raster calculator
1. Choose File → New Project
2. Click Layer → Add Raster Layer...
3. Open /home/user/data/raster/SRTM_u03_n041e002.tif
4. Click Raster → Raster calculator...
5. Enter output raster file and a formula:
6. Double click mountains in the Layers tree and set the color map style to Pseudocolor
5
8. QGIS Workshop Documentation, Release 1.0
7. Combine both rasters to remove all points lower than 1000 meters:
8. The resulting raster is a DEM without the points lower than 1000 meters:
3.1. Using the raster calculator 6
10. CHAPTER
FOUR
FORMS
4.1 Custom entry form
1. Choose File → Open Project... from the menu bar
2. Select QGIS-NaturalEarth-Example.qgs and press Open
3. Zoom in somewhere to speed up redrawing
4. Click Layer → Add PostGIS Layer....
5. Press Connect on NaturalEarth connection
6. Select 10m_populated_places_simple in the table list
7. Press Add and Close
8. Double click 10m_populated_places_simple in the Layers tree
9. Go to the tab Fields and set the Edit widget types:
10. For the field ISO_A2 create a value map loading data from a layer:
8
11. QGIS Workshop Documentation, Release 1.0
11. Activate the edit mode and digitize a point to see the new edit form:
4.2 Forms with QT Designer
QGIS supports also custom forms, created with the QT GUI Designer. QGIS relies on naming conventions for data
fields and expressions. This allows QGIS to run forms created with QT designer without compilation.
For installing QT designer, open a terminal:
1. Click Applications → Accessories → Terminal Emulator
2. Type sudo apt-get install qt4-designer (Password: user)
Now we create a custom form with QT Designer:
4.2. Forms with QT Designer 9
12. QGIS Workshop Documentation, Release 1.0
1. Click Applications → Development → QT 4 Designer
2. Select “Dialog with Buttons Bottom”
We follow the article on http://woostuff.wordpress.com/2011/09/05/qgis-tips-custom-feature-forms-with-
python-logic/
In our case we create an entry form “My custom places” with an entry field name and a read only key field gid
3. Save it as places.ui in /home/user
Open QGIS again and:
1. Double click 10m_populated_places_simple in the Layers tree
2. Go to the tab General, choose /home/user/places.ui as Edit UI and press OK
3. Activate the edit mode and digitize a point to see your new custom form
4.2. Forms with QT Designer 10
13. CHAPTER
FIVE
TABLE JOIN
5.1 Table Join Admin1 -> Admin0
1. Choose File → Open Project... from the menu bar
2. Select QGIS-NaturalEarth-Example.qgs and press Open
3. Zoom in somewhere to speed up redrawing
4. Click Layer → Add PostGIS Layer....
5. Press Connect on NaturalEarth connection
6. Select 10m_admin_0_countries and 10m_admin_1_states_provinces in the table list
7. Press Add and Close
8. Double click 10m_admin_1_states_provinces in the Layers tree
9. Go to the tab Joins and press the + button
10. Select 10m_admin_0_countries, adm0_a3, adm0_a3 and press OK:
11. To see the joined information, right click 10m_admin_1_states_provinces in the Layers tree and select
Open attribute table
11
14. QGIS Workshop Documentation, Release 1.0
• You should see all admin0 attributes at the end of a admin line
5.1. Table Join Admin1 -> Admin0 12
15. CHAPTER
SIX
NEW SYMBOLOGY FEATURES
• Three new classification modes added to graduated symbol renderer http://linfiniti.com/2010/09/new-class-
breaks-for-graduated-symbols-in-qgis/
• Data-defined rotation and size for categorized and graduated renderer (symbology-ng).
6.1 Multiple symbol layers for road symbolization
1. Choose File → Open Project... from the menu bar
2. Select QGIS-NaturalEarth-Example.qgs and press Open
3. Zoom in somewhere to speed up redrawing
4. Click Layer → Add Vector Layer from the menu bar
5. Press Browse and navigate to /home/user/data/north_carolina/shape/roadsmajor.shp and
press Open
6. Go to the tab Coordinate Reference System (CRS), check Enable ‘on the fly’ CRS transformation and press Ok
7. Right click roadsmajor in the Layers tree and select Zoom to layer extent
8. Double click roadsmajor in the Layers tree and activate the Style tab
9. Press the Change button to edit the line symbol
10. Change the color to black and set 2mm pen width
11. Press + to add a second symbol layer
12. Change the color to white and set 1mm pen width
13
16. QGIS Workshop Documentation, Release 1.0
13. Press Ok and Apply
• You should see the major roads, but with artefacts at the end of line segments
14. Press the Symbol levels button and check Enable symbol levels
15. Press Ok and Ok again to close the Layer properties
• You should see the major roads with the black symbol layer draws first and the white layer on top
6.1. Multiple symbol layers for road symbolization 14
17. CHAPTER
SEVEN
ADVANCED LABELLING
• Data defined label position in labeling-ng http://linfiniti.com/2011/03/interactive-label-placement-in-qgis-1-7/
7.1 Labelling of city layer
1. Choose File → Open Project... from the menu bar
2. Select QGIS-NaturalEarth-Example.qgs and press Open
3. Check 10m_populated_places_simple in the Layers tree
4. Click labelling tool (ABC) in the toolbar
5. Activate layer labelling with the following settings and press Apply:
6. Click on tab Data defined settings, set a data defined font size and press Apply:
15
18. QGIS Workshop Documentation, Release 1.0
7.2 Diagrams
1. Choose File → Open Project... from the menu bar
2. Select QGIS-NaturalEarth-Example.qgs and press Open
3. Double click 10m_populated_places_simple in the Layers tree
4. Activate diagram display with the following settings and press Apply:
7.2. Diagrams 16
19. CHAPTER
EIGHT
WORKING WITH WFS(-T) LAYERS
OSGeo-Live contains TinyOWS, a high performance, Transactional Web Feature Service (WFS-T) which is light
weight and easy to deploy, using a CGI or FastCGI interface and using PostGIS for data storage.
8.1 Display a WFS layer with QGIS
1. Click Layer → Add PostGIS Layer....
• We display the original PostGIS layer first
2. Press New.
3. Fill in pgrouting as Connection name and Database
4. Press OK.
5. Press Connect.
6. Select ways in the table list
7. Press Add.
8. Zoom in
9. Select Plugins –> Manage Plugins –> WFS Plugin -> OK
• Enable the WFS Layer plugin.
10. Click Layer → Add WFS Layer....
• Now we add a WFS layer based on the same table
11. Press New.
12. Fill in tinyows as name http://localhost/cgi-bin/tinyows as URL
13. Press OK.
14. Press Connect.
15. Select ows:ways in the layer list
16. Check Only request features overlapping the current view extent.
17. Press OK.
• WFS layer is now displayed:
17
20. QGIS Workshop Documentation, Release 1.0
8.2 Edit data with WFS-T
1. Click Layer → Toggle Editing.
2. Click Edit → Node Tool.
3. Move a vertex (cross) to another position
4. Click Layer → Save edits.
5. Hide layer unchecking tows:ways in the layer list
• You should see the edited way in an other color, coming directly from PostGIS.
8.2. Edit data with WFS-T 18
21. CHAPTER
NINE
WORKING WITH QGIS SERVER
QGIS Server provides a web map service (WMS) based on libraries from the Quantum GIS (QGIS) desktop applica-
tion.
This Quick Start describes how to:
• update an existing QGIS project and render it with QGIS Server
• create a new QGIS project and open the WMS directly in a browser
Documentation:
• http://www.qgis.org/wiki/QGIS_Server_Tutorial
Quick start for Server Installation on Debian/Ubuntu:
• apt-get install qgis-mapserver libapache2-mod-fcgid
• -> http://localhost/cgi-bin/qgis_mapserv.fcgi
QGIS Web Client:
• https://github.com/qgis/qgis-web-client
9.1 Start GeoExt viewer
OSGeo-Live contains an example of web map viewer based on the GeoExt Javascript framework and using QGIS
Server for rendering the map.
• Click Geospatial → Web Services → QGIS Server
You should see a browser window with a web map viewer showing a world map.
19
22. QGIS Workshop Documentation, Release 1.0
We will now change the map styling using QGIS.
9.2 Edit QGIS project
1. Click Geospatial → Desktop GIS → Quantum GIS.
2. Choose File → Open Project... from the menu bar.
3. Select QGIS-NaturalEarth-Example.qgs and press Open.
• You should see the same world map rendered by QGIS. We will now change river styling and look at the
result in the web map viewer.
4. Double click 10m_rivers_lake_centerlines in the Layers tree.
5. Change the color in Outline Options to a different blue tone.
6. Press OK.
• Rivers are now rendered in a new color.
7. Save the project with File → Save Project.
8. Reopen the web browser
9. Zoom in
• You should now see rivers rendered in the same new color.
9.2. Edit QGIS project 20
23. QGIS Workshop Documentation, Release 1.0
9.3 Create a new QGIS project
1. Reopen QGIS
2. Choose File → New Project.
3. Click Layer → Add Vector Layer....
4. Browse to dataset /home/user/data/natural_earth/10m_admin_0_countries.shp.
5. Press Open.
• You should see all world countries.
6. Save the project with File → Save Project.
7. Use file name /home/user/world.qgs and press Save.
8. Open the WMS URL (http://localhost/cgi-bin/qgis_mapserv?map=/home/user/world.qgs&SERVICE=WMS&VERSION=1.3.0&R
91.901820,-180.000000,83.633800,180.000000&CRS=EPSG:4326&WIDTH=722&HEIGHT=352&LAYERS=10m_admin_0_co
• You should see all world countries, this time rendered by QGIS Server.
9.3. Create a new QGIS project 21
24. CHAPTER
TEN
PLUGINS
10.1 Popular plugins
• GDAL raster tools
• Openlayers Plugin
• NumericalDigitize (Create points from coordinates)
• Points2One (Create polygos or lines from points)
• TableManager (Delete attributes from shape files)
• 1-Band Raster Colour Table (Create colormaps for raster layers quickly)
• PostGIS versioning http://www.kappasys.ch/cms/index.php?id=23&L=5
• Offline editing http://www.sourcepole.ch/2010/9/29/offline-editing-plugin-for-qgis
• Routing (Road graph plugin) http://gis-lab.info/qa/road-graph-eng.html
22