Docs in progress for ‘QGIS testing’. Visit for QGIS 2.18 docs and translations.

1.2. Preparing Exercise Data


This process is intended for course conveners, or more experienced QGIS users who wish to create localised sample data sets for their course. Default data sets are provided with the Training Manual, but you may follow these instructions if you wish to replace the default data sets.

The sample data provided with the Training Manual refers to the town of Swellendam and its surroundings. Swellendam is located about 2 hours’ east of Cape Town in the Western Cape of South Africa. The dataset contains feature names in both English and Afrikaans.

Anyone can use this dataset without difficulty, but you may prefer to use data from your own country or home town. If you choose to do so, your localised data will be used in all lessons from Module 3 to Module 7.2. Later modules use more complex data sources which may or may not be available for your region.


These instructions assume you have a good knowledge of QGIS and are not intended to be used as teaching material.

1.2.1. hard Try Yourself Create OSM based vector Files

If you wish to replace the default data set with localised data for your course, this can easily be done with tools built into QGIS. The region you choose to use should have a good mix of urban and rural areas, containing roads of differing significance, area boundaries (such as nature reserves or farms) and surface water, such as streams and rivers.

  1. Open a new QGIS project;

  2. Select Layer ‣ Data Source Manager to open the Data Source Manager dialog;

  3. In the Browser tab, expand the XYZ Tiles drop-down menu and double-click the OpenStreetMap item.


    A map of the world is now visible on the map canvas;

  4. Close the Data Source Manager dialog;

  5. Move to the area you’d like to use as study area.


Now that we have the area we’ll extract the data from, let’s enable the extraction tools.

  1. Go to Plugins ‣ Manage/Install Plugins…

  2. In the All tab, type QuickOSM in the search box;

  3. Select the QuickOSM plugin, press Install Plugin and then Close the dialog;

  4. Execute the new plugin from Vector ‣ QuickOSM ‣ QuickOSM

  5. In the Quick query tab, select building in the Key drop-down menu;

  6. Leave empty the Value field, meaning that you are querying any building;

  7. Select Canvas Extent in the next drop-down menu;

  8. Expand the Advanced group below and uncheck on the right all geometry types except Multipolygons;

  9. Press Run query;


    A new building layer is added to the Layers panel, showing buildings in the selected extent.

  10. Proceed as above to extract other data:

    1. Key = landuse and Multipolygons geometry type;
    2. Key = natural, Value = water and Multipolygons geometry type;
    3. Key = place and Points geometry type;
    4. Key = highway and check Lines and Multilines geometry types;
    5. Key = waterway, Value = river and check Lines and Multilines geometry types;

The above process adds the layers as temporary files (indicated by the indicatorMemory icon next to their name).


You can sample the data your region contains in order to see what kind of results your region will yield.

We now need to save the resulting data as a shapefile for you to use during your course:

  1. Click the indicatorMemory icon next to the building layer, opening the Save Scratch Layer dialog;


    If you need to replace some particular properties (CRS, extent, fields…) of the temporary layer, use instead the Export ‣ Save Features as… contextual menu, and ensure the Add saved file to map option is checked. A new layer is added in such case.

  2. Make sure the format is ESRI Shapefile;

  3. Use the button to browse to the exercise_data/shapefile/ folder and save the file as buildings.shp;

  4. Press OK;

    In the Layers panel, the temporary building layer is swapped in place with the saved buildings shapefile layer and the temporary icon next to it removed.

  5. Repeat the process for other layers, renaming them as follows:

    • natural_water into water;
    • waterway_river into rivers;
    • place into places;
    • highway into roads.

    Each resulting data set should be saved in the exercise_data/shapefile/ directory.


    For convenience, you’ll also need to rename each layer: double-click the layer to open its Layer Properties ‣ Source tab and update the Layer name property accordingly.

The last step is to create a spatiaLite file from the landuse layer to use during the course:

  1. Click the indicatorMemory icon next to the landuse layer;

  2. Select the SpatiaLite format;

  3. save the file as landuse.sqlite under the exercise_data/ folder. By default, the Layer name is filled as the file name. Do not change it.

  4. Press OK.

You should now have a map which looks something like this (the symbology will certainly be very different, but that is fine):


The important thing is that you have 6 vector layers matching those shown above and that all those layers have some data.

1.2.2. hard Try Yourself Create SRTM DEM tiff Files

For modules Module: Creating Vector Data and Module: Rasters, you’ll also need raster images (SRTM DEM) which cover the region you have selected for your course.

The CGIAR-CGI ( provides some SRTM DEM you can download from

You’ll need images which cover the entire region you have chosen to use. To find the extent coordinates, in QGIS , zoomToLayer zoom to the extent of the largest layer and pick the values in the extents Extents box of the status bar. Keep the GeoTiff format. Once the form is filled, click on the Click here to Begin Search >> button and download the file(s).

Once you have downloaded the required file(s), they should be saved in the exercise_data directory, under raster/SRTM subfolders.

1.2.3. hard Try Yourself Create imagery tiff Files

In Module Module: Creating Vector Data, Follow Along: Data Sources lesson shows close-up images of three school sports fields which students are asked to digitize. You’ll therefore need to reproduce these images using your new SRTM DEM tiff file(s). There is no obligation to use school sports fields: any three school land-use types can be used (e.g. different school buildings, playgrounds or car parks).

For reference, the image in the example data is:


1.2.4. basic Try Yourself Replace Tokens

Having created your localised dataset, the final step is to replace the tokens in the substitutions.txt file so that the appropriate names will appear in your localised version of the Training Manual.

The tokens you need to replace are as follows:

  • majorUrbanName: this defaults to “Swellendam”. Replace with the name of the major town in your region.
  • schoolAreaType1: this defaults to “athletics field”. Replace with the name of the largest school area type in your region.
  • largeLandUseArea: this defaults to “Bontebok National Park”. Replace with the name of a large landuse polygon in your region.
  • srtmFileName: this defaults to srtm_41_19.tif. Replace this with the filename of your SRTM DEM file.
  • localCRS: this defaults to WGS 84 / UTM 34S. You should replace this with the correct CRS for your region.