Chapter 1
Chapter 1
QGIS Project
1 Course Introduction 1
1.1 Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Why QGIS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.3 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.4 Sponsoring Chapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.5 Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.6 Individual Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.7 Sponsors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.8 Source files and Issue reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.9 Latest Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 About the exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 How to use this tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.2 Tiered course objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
i
2.4.10 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.4.11 Follow Along: Symbol layer types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.4.12 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.4.13 Follow Along: Geometry generator symbology . . . . . . . . . . . . . . . . . . . . . . . 42
2.4.14 Follow Along: Creating a Custom SVG Fill . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.4.15 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.4.16 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.4.17 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ii
5.1.4 Follow Along: Using Vertex Editor Table . . . . . . . . . . . . . . . . . . . . . . . . . . 130
5.1.5 Try Yourself Digitizing Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
5.1.6 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
5.1.7 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
5.2 Lesson: Feature Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
5.2.1 Follow Along: Snapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
5.2.2 Follow Along: Correct Topological Features . . . . . . . . . . . . . . . . . . . . . . . . 138
5.2.3 Follow Along: Tool: Simplify Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
5.2.4 Try Yourself Tool: Add Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.2.5 Try Yourself Tool: Add Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.2.6 Follow Along: Tool: Reshape Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.2.7 Try Yourself Tool: Split Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
5.2.8 Try Yourself Tool: Merge Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5.2.9 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5.2.10 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5.3 Lesson: Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5.3.1 Follow Along: Using QGIS’ Form Design Functionality . . . . . . . . . . . . . . . . . . 148
5.3.2 Try Yourself Using the Form to Edit Values . . . . . . . . . . . . . . . . . . . . . . . . 149
5.3.3 Follow Along: Setting Form Field Types . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.3.4 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5.3.5 Try Yourself Creating Test Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5.3.6 Follow Along: Creating a New Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
5.3.7 Follow Along: Associating the Form with Your Layer . . . . . . . . . . . . . . . . . . . 156
5.3.8 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
5.3.9 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
5.3.10 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
5.4 Lesson: Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
5.4.1 Follow Along: Add a Field for Images . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
5.4.2 Follow Along: Creating an Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.4.3 Follow Along: Searching the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
5.4.4 Follow Along: Open a Webpage Directly in QGIS . . . . . . . . . . . . . . . . . . . . . 167
5.4.5 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
5.4.6 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
iii
6.3 Lesson: Network Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
6.3.1 Follow Along: The Tools and the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
6.3.2 Calculate the shortest path (point to point) . . . . . . . . . . . . . . . . . . . . . . . . . 195
6.3.3 Try Yourself Fastest path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
6.3.4 Follow Along: Advanced options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
6.3.5 Shortest path with speed limit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
6.3.6 Service area (from layer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
6.3.7 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
6.3.8 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
6.4 Lesson: Spatial Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
6.4.1 Follow Along: Create a Test Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
6.4.2 Follow Along: Basic Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
6.4.3 Follow Along: Compute statistics on distances between points . . . . . . . . . . . . . . . 210
6.4.4 Follow Along: Nearest Neighbor Analysis (within layer) . . . . . . . . . . . . . . . . . . 212
6.4.5 Follow Along: Mean Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
6.4.6 Follow Along: Image Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
6.4.7 Follow Along: Spatial Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
6.4.8 Try Yourself Different interpolation methods . . . . . . . . . . . . . . . . . . . . . . . . 217
6.4.9 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
6.4.10 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
iv
8.1.5 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
8.2 Lesson: Combining the Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
8.2.1 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
8.2.2 Try Yourself Inspecting the Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
8.2.3 Try Yourself Refining the Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
8.2.4 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
8.2.5 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
8.3 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
8.4 Lesson: Supplementary Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
8.4.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
8.4.2 Solution Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
8.4.3 Follow Along: Setting up the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
8.4.4 Loading Data into the Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
8.4.5 Changing the layer order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
8.4.6 Find the Correct Districts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
8.4.7 Clip the Rasters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
8.4.8 Changing the symbology of vector layers . . . . . . . . . . . . . . . . . . . . . . . . . . 261
8.4.9 Changing the symbology of raster layers . . . . . . . . . . . . . . . . . . . . . . . . . . 261
8.4.10 Clean up the map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
8.4.11 Create the hillshade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
8.4.12 Slope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
8.4.13 Try Yourself Aspect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
8.4.14 Reclassifying rasters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
8.4.15 Combining rasters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
8.4.16 Finding rural areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
8.4.17 Creating a negative buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
8.4.18 Vectorizing the raster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
8.4.19 Fixing geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
8.4.20 Determining the Intersection of vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
8.4.21 Calculating the area for each polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
8.4.22 Selecting areas of a given size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
8.4.23 Digitize the University of Cape Town . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
8.4.24 Find the locations that are closest to the University of Cape Town . . . . . . . . . . . . . 268
v
10.2 Lesson: Web Feature Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
10.2.1 Follow Along: Loading a WFS Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
10.2.2 Follow Along: Querying a WFS Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
10.2.3 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
10.2.4 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
vi
14.2.3 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
14.2.4 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
14.3 Lesson: Digitizing Forest Stands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
14.3.1 Follow Along: Extracting the Forest Stands Borders . . . . . . . . . . . . . . . . . . . . 355
14.3.2 Try Yourself Georeference the Green Pixels Image . . . . . . . . . . . . . . . . . . . . . 358
14.3.3 Follow Along: Creating Supporting Points for Digitizing . . . . . . . . . . . . . . . . . . 358
14.3.4 Follow Along: Digitize the Forest Stands . . . . . . . . . . . . . . . . . . . . . . . . . . 360
14.3.5 Try Yourself Finish Digitizing the Forest Stands . . . . . . . . . . . . . . . . . . . . . . 365
14.3.6 Follow Along: Joining the Forest Stand Data . . . . . . . . . . . . . . . . . . . . . . . . 366
14.3.7 Try Yourself Renaming Attribute Names and Adding Area and Perimeter . . . . . . . . . 367
14.3.8 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
14.3.9 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
14.4 Lesson: Updating Forest Stands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
14.4.1 Comparing the Old Forest Stands to Current Aerial Photographs . . . . . . . . . . . . . . 369
14.4.2 Interpreting the CIR Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
14.4.3 Try Yourself Digitizing Forest Stands from CIR Imagery . . . . . . . . . . . . . . . . . . 372
14.4.4 Follow Along: Updating Forest Stands with Conservation Information . . . . . . . . . . . 373
14.4.5 Try Yourself Updating Forest Stands with Distance to the Stream . . . . . . . . . . . . . 378
14.4.6 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
14.4.7 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
14.5 Lesson: Systematic Sampling Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
14.5.1 Inventorying the Forest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
14.5.2 Follow Along: Implementing a Systematic Sampling Plot Design . . . . . . . . . . . . . . 379
14.5.3 Follow Along: Exporting Sample Plots as GPX format . . . . . . . . . . . . . . . . . . . 383
14.5.4 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
14.5.5 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
14.6 Lesson: Creating Detailed Maps with the Atlas Tool . . . . . . . . . . . . . . . . . . . . . . . . . 384
14.6.1 Follow Along: Preparing the Print Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 384
14.6.2 Follow Along: Adding Background Map . . . . . . . . . . . . . . . . . . . . . . . . . . 386
14.6.3 Try Yourself Changing the Symbology of the Layers . . . . . . . . . . . . . . . . . . . . 387
14.6.4 Try Yourself Create a Basic Map Template . . . . . . . . . . . . . . . . . . . . . . . . . 388
14.6.5 Follow Along: Adding More Elements to the Print Layout . . . . . . . . . . . . . . . . . 389
14.6.6 Follow Along: Creating an Atlas Coverage . . . . . . . . . . . . . . . . . . . . . . . . . 391
14.6.7 Follow Along: Setting Up the Atlas Tool . . . . . . . . . . . . . . . . . . . . . . . . . . 394
14.6.8 Follow Along: Editing the Coverage Layer . . . . . . . . . . . . . . . . . . . . . . . . . 396
14.6.9 Follow Along: Printing the Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
14.6.10 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
14.6.11 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
14.7 Lesson: Calculating the Forest Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
14.7.1 Follow Along: Adding the Inventory Results . . . . . . . . . . . . . . . . . . . . . . . . 400
14.7.2 Follow Along: Whole Forest Parameters Estimation . . . . . . . . . . . . . . . . . . . . 401
14.7.3 Follow Along: Estimating Stand Parameters . . . . . . . . . . . . . . . . . . . . . . . . 401
14.7.4 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
14.7.5 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
14.8 Lesson: DEM from LiDAR Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
14.8.1 Follow Along: Installing Lastools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
14.8.2 Follow Along: Calculating a DEM with LAStools . . . . . . . . . . . . . . . . . . . . . 408
14.8.3 Follow Along: Creating a Terrain Hillshade . . . . . . . . . . . . . . . . . . . . . . . . . 413
14.8.4 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
14.8.5 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
14.9 Lesson: Map Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
14.9.1 Follow Along: Preparing the Map Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
14.9.2 Try Yourself Try Different Blending Modes . . . . . . . . . . . . . . . . . . . . . . . . 418
14.9.3 Try Yourself Using a Layout Template to Create the Map result . . . . . . . . . . . . . . 419
14.9.4 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
vii
15.1.1 What is a Database? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
15.1.2 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
15.1.3 Columns / Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
15.1.4 Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
15.1.5 Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
15.1.6 Modelling an Address Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
15.1.7 Database Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
15.1.8 Normalisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
15.1.9 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
15.1.10 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
15.1.11 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
15.1.12 Entity Relationship Diagramming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
15.1.13 Constraints, Primary Keys and Foreign Keys . . . . . . . . . . . . . . . . . . . . . . . . 427
15.1.14 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
15.1.15 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
15.1.16 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
15.2 Lesson: Implementing the Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
15.2.1 Install PostgreSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
15.2.2 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
15.2.3 Create a database user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
15.2.4 Verify the new account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
15.2.5 Create a database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
15.2.6 Starting a database shell session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
15.2.7 Make Tables in SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
15.2.8 Create Keys in SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
15.2.9 Create Indexes in SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
15.2.10 Dropping Tables in SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
15.2.11 A word on pgAdmin III . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
15.2.12 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
15.2.13 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
15.3 Lesson: Adding Data to the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
15.3.1 Insert statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
15.3.2 Sequencing Data Addition According to Constraints . . . . . . . . . . . . . . . . . . . . 435
15.3.3 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
15.3.4 Select data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
15.3.5 Update data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
15.3.6 Delete Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
15.3.7 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
15.3.8 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
15.3.9 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
15.4 Lesson: Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
15.4.1 Ordering Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
15.4.2 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
15.4.3 Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
15.4.4 Sub-Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
15.4.5 Aggregate Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
15.4.6 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
15.4.7 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
15.5 Lesson: Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
15.5.1 Creating a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
15.5.2 Modifying a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
15.5.3 Dropping a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
15.5.4 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
15.5.5 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
15.6 Lesson: Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
15.6.1 Creating a logging rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
15.6.2 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
15.6.3 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
viii
16 Module: Spatial Database Concepts with PostGIS 445
16.1 Lesson: PostGIS Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
16.1.1 Installing under Ubuntu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
16.1.2 Installing under Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
16.1.3 Installing on Other Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
16.1.4 Configuring Databases to use PostGIS . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
16.1.5 Looking at the installed PostGIS functions . . . . . . . . . . . . . . . . . . . . . . . . . 446
16.1.6 Spatial Reference Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
16.1.7 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
16.1.8 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
16.2 Lesson: Simple Feature Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
16.2.1 What is OGC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
16.2.2 What is the SFS Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
16.2.3 Add a geometry field to table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
16.2.4 Add a constraint based on geometry type . . . . . . . . . . . . . . . . . . . . . . . . . . 449
16.2.5 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
16.2.6 Populate geometry_columns table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
16.2.7 Add geometry record to table using SQL . . . . . . . . . . . . . . . . . . . . . . . . . . 450
16.2.8 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
16.2.9 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
16.3 Lesson: Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
16.3.1 shp2pgsql . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
16.3.2 pgsql2shp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
16.3.3 ogr2ogr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
16.3.4 DB Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
16.3.5 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
16.3.6 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
16.4 Lesson: Spatial Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
16.4.1 Spatial Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
16.4.2 Spatial Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
16.4.3 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
16.4.4 PostGIS Spatial Functions Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
16.4.5 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
16.4.6 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
16.5 Lesson: Geometry Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
16.5.1 Creating Linestrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
16.5.2 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
16.5.3 Creating Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
16.5.4 Exercise: Linking Cities to People . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
16.5.5 Looking at Our Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
16.5.6 Try Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
16.5.7 Access Sub-Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
16.5.8 Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
16.5.9 Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
16.5.10 Building Geometries from Other Geometries . . . . . . . . . . . . . . . . . . . . . . . . 466
16.5.11 Geometry Cleaning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
16.5.12 Differences between tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
16.5.13 Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
16.5.14 In Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
ix
17.8 Running an external algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
17.9 The processing log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
17.9.1 Advanced . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
17.10 The raster calculator. No-data values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
17.11 Vector calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
17.12 Defining extents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
17.13 HTML outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
17.14 First analysis example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
17.15 Clipping and merging raster layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
17.16 Hydrological analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
17.17 Starting with the graphical modeler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
17.18 More complex models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
17.19 Numeric calculations in the modeler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
17.20 A model within a model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
17.21 Using modeler-only tools for creating a model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
17.22 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
17.23 More interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
17.24 Iterative execution of algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
17.25 More iterative execution of algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
17.26 The batch processing interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
17.27 Models in the batch processing interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
17.28 Pre- and post-execution script hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
17.29 Other programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
17.29.1 GRASS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
17.29.2 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
17.29.3 Others . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
17.29.4 Comparison among backends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
17.30 Interpolation and contouring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
17.30.1 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
17.30.2 Contour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
17.31 Vector simplification and smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
17.32 Planning a solar farm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
17.33 Use R scripts in Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
17.33.1 Adding scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
17.33.2 Creating plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
17.33.3 Create a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
17.33.4 Text and graph output from R - syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
17.34 Predicting landslides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
x
19 Appendix: Contributing To This Manual 629
19.1 Downloading Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
19.2 Manual Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
19.3 Adding a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
19.4 Adding a Lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630
19.5 Adding a Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
19.5.1 Adding a “follow along” section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
19.5.2 Adding a “try yourself” section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
19.6 Add a Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
19.7 Add a Further Reading Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
19.8 Add a What’s Next Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
19.9 Using Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
19.9.1 New concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
19.9.2 Emphasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
19.9.3 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
19.9.4 Internal links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
19.9.5 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
19.9.6 Using monospaced text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
19.9.7 Labeling GUI items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
19.9.8 Menu selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
19.9.9 Adding notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
19.9.10 Adding a sponsorship/authorship note . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
19.10 Thank You! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
xi
21.8.5 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664
21.9 Results For Vector Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
21.9.1 Distance from High Schools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
21.9.2 Distance from Restaurants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
21.10 Results For Network Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
21.11 Fastest path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
21.12 Results For Raster Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
21.12.1 Calculate Aspect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
21.12.2 Calculate Slope (less than 2 and 5 degrees) . . . . . . . . . . . . . . . . . . . . . . . . . 673
21.13 Results For Completing the Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676
21.13.1 Raster to Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676
21.13.2 Inspecting the Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
21.13.3 Refining the Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
21.14 Results For WMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
21.14.1 Adding Another WMS Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
21.14.2 Adding a New WMS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683
21.14.3 Finding a WMS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
21.15 Results For GRASS Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
21.15.1 Add Layers to Mapset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
21.15.2 Reclassify raster layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
21.16 Results For Database Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
21.16.1 Address Table Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
21.16.2 Normalising the People Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687
21.16.3 Further Normalisation of the People Table . . . . . . . . . . . . . . . . . . . . . . . . . 687
21.16.4 Create a People Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688
21.16.5 The DROP Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
21.16.6 Insert a New Street . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
21.16.7 Add a New Person With Foreign Key Relationship . . . . . . . . . . . . . . . . . . . . . 689
21.16.8 Return Street Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
21.17 Results For Spatial Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
21.17.1 The Units Used in Spatial Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
21.17.2 Creating a Spatial Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
21.18 Results For Geometry Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
21.18.1 Creating Linestrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
21.18.2 Linking Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
21.19 Results For Simple Feature Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
21.19.1 Populating Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
21.19.2 Populate the Geometry_Columns Table . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
21.19.3 Adding Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
xii
CHAPTER
ONE
COURSE INTRODUCTION
1.1 Foreword
Welcome to our course! We will be showing you how to use QGIS easily and efficiently. If you are new to GIS,
we will tell you what you need to get started. If you are an experienced user, you will see how QGIS fulfills all the
functions you expect from a GIS program, and more!
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, as in lunch. Installing and using the QGIS program costs you a grand total of zero money. No initial
fee, no recurring fee, nothing.
• It’s free, as in liberty. If you need extra functionality in QGIS, you can do more than just hope it will be included
in the next release. You can sponsor the development of a feature, or add it yourself if you are familiar with
programming.
• 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, these exercises will make you know how.
1.1.2 Background
In 2008 we launched the Gentle Introduction to GIS, a completely free, open content resource for people who want to
learn about GIS without being overloaded with jargon and new terminology. It was sponsored by the South African
government and has been a phenomenal success, with people all over the world writing to us to tell us how they are
using the materials to run University Training Courses, teach themselves GIS and so on. The Gentle Introduction is not
a software tutorial, but rather aims to be a generic text (although we used QGIS in all examples) for someone learning
about GIS. There is also the QGIS manual which provides a detailed functional overview of the QGIS application.
However, it is not structured as a tutorial, but rather as a reference guide. At Linfiniti Consulting CC. we frequently
run training courses and have realised that a third resource is needed - one that leads the reader sequentially through
learning the key aspects of QGIS in a trainer-trainee format - which prompted us to produce this work.
This training manual is intended to provide all the materials needed to run a 5 day course on QGIS, PostgreSQL and
PostGIS. The course is structured with content to suit novice, intermediate and advanced users alike and has many
exercises complete with annotated answers throughout the text.
1
QGIS Training Manual
1.1.3 License
The Free Quantum GIS Training Manual by Linfiniti Consulting CC. is based on an earlier version from Linfiniti and
is licensed under a Creative Commons Attribution 4.0 International. Permissions beyond the scope of this license
may be available at below.
We have published this QGIS training manual under a liberal license that allows you to freely copy, modify and
redistribute this work. A complete copy of the license is available at the end of this document. In simple terms, the
usage guidelines are as follows:
• You may not represent this work as your own work, or remove any authorship text or credits from this work.
• You may not redistribute this work under more restrictive permissions than those under which it was provided
to you.
• If you add a substantive portion to the work and contribute it back to the project (at least one complete module)
you may add your name to the end of the authors list for this document (which will appear on the front page)
• If you contribute minor changes and corrections you may add yourself to the contributors list below.
• If you translate this document in its entirety, you may add your name to the authors list in the form “Translated
by Joe Bloggs”.
• If you sponsor a module or lesson, you may request the author to include an acknowledgement in the beginning
of each lesson contributed, e.g.:
• If you are unsure about what you may do under this license, please contact us at office@linfiniti.com and we
will advise you if what you intend doing is acceptable.
• If you publish this work under a self publishing site such as https://www.lulu.com we request that you donate
the profits to the QGIS project.
• You may not commercialise this work, except with the expressed permission of the authors. To be clear, by
commercialisation we mean that you may not sell for profit, create commercial derivative works (e.g. selling
content for use as articles in a magazine). The exception to this is if all the profits are given to the QGIS project.
You may (and we encourage you to do so) use this work as a text book when conducting training courses, even
if the course itself is commercial in nature. In other words, you are welcome to make money by running a
training course that uses this work as a text book, but you may not profit off the sales of the book itself - all
such profits should be contributed back to QGIS.
This work is by no means a complete treatise on all the things you can do with QGIS and we encourage others to add
new materials to fill any gaps. Linfiniti Consulting CC. can also create additional materials for you as a commercial
service, with the understanding that all such works produced should become part of the core content and be published
under the same license.
1.1.5 Authors
• Rüdiger Thiede (rudi@linfiniti.com) - Rudi has written the QGIS instructional materials and parts of the Post-
GIS materials.
• Tim Sutton (tim@linfiniti.com) - Tim has overseen and guided the project and co-authored the PostgreSQL
and PostGIS parts. Tim also authored the custom sphinx theme used for this manual.
• Horst Düster ([email protected] ) - Horst co-authored the PostgreSQL and PostGIS parts
• Marcelle Sutton (marcelle@linfiniti.com) - Marcelle provided proof-reading and editorial advice during the
creation of this work.
1.1.7 Sponsors
The source of this document is available at GitHub QGIS Documentation repository. Consult GitHub.com for in-
structions on how to use the git version control system.
Despite our efforts, you could find some errors or miss some information while following this training. Please report
them at https://github.com/qgis/QGIS-Documentation/issues.
You can always obtain the latest version of this document by visiting the online version which is part of the QGIS
documentation website (https://docs.qgis.org).
Note: The documentation website contains links to both online and PDF versions of the Training manual and other
parts of the QGIS documentation.
Now that you know why you want to use QGIS, we can show you how.
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!
Any text that looks like this refers to something that you can see in the QGIS user interface.
Text that looks ► like ► this directs you through menus.
This kind of text refers to something you can type, such as a command.
This/kind/of.text refers to a path or filename.
This+That refers to a keyboard shortcut comprised of two buttons.
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
In this category, the course assumes that you have little or no prior experience with theoretical GIS knowledge or the
operation of GIS software.
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.
Intermediate
In this category, it is assumed that you have working knowledge and experience of the everyday uses of GIS software.
Building on 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
for everyday use.
Advanced
In this category, the assumption is that you are experienced with GIS software, have knowledge of and experience
with spatial databases, using data on a remote server, perhaps writing scripts for analysis purposes, etc.
Building on 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 the QGIS plugin system, database access, 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.
1.2.3 Data
The sample data that accompanies this resource is freely available and comes from the following sources:
• Streets and Places datasets from OpenStreetMap (https://www.openstreetmap.org/)
• Property boundaries (urban and rural), water bodies from NGI (http://www.ngi.gov.za/)
• SRTM DEM from the CGIAR-CGI (http://srtm.csi.cgiar.org/)
Download the prepared dataset from the Training data repository and unzip the file. All the necessary data are
provided in the exercise_data folder.
If you are an instructor, and would like to use more relevant data, you will find instructions for creating local data in
the Preparing Exercise Data appendix.