2. Preparing Exercise Data

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.

Note

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.

Note

The sample data used throughout the manual can be downloaded here: http://qgis.org/downloads/data/training_manual_exercise_data.zip

2.1. hard Try Yourself

Note

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

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.

  • Ouvrez un nouveau projet QGIS

  • Dans la liste déroulante du menu Vecteur, sélectionnez OpenStreetMap -> Télécharger des données. Vous pouvez ensuite manuellement entrer les coordonnées de la région qui vous intéresse ou utiliser une couche existante pour définir ces coordonnées.

  • Choisissez un dossier pour sauvegarder le fichier .osm résultant et cliquez Ok:

../../../_images/set_osm_region.png
  • Vous pouvez ensuite ouvrir le fichier .osm à l’aide du bouton Ajouter une couche vecteur. Vous pourriez avoir besoin d’afficher Tous les fichiers dans la fenêtre de l’explorateur. Vous pouvez également opter pour un glisser-déposer du fichier dans la fenêtre de QGIS.

  • Dans la fenêtre qui s’ouvre, sélectionnez toutes les couches, à l’exception de other_relations et multilinestrings:

../../../_images/select_osm_layers.png

Quatre couches dont le nom répond aux conventions de nommage OSM vont être chargées dans votre carte (vous pourriez avoir besoin de zoomer/dézoomer pour voir les données vecteur).

../../../_images/osm_data_loaded.png

Il nous faut extraire les données utiles de ces couches, les renommer et créer les shapefiles correspondants:

  • Tout d’abord, faites un double-clic sur la couche multipolygons afin d’ouvrir la fenêtre Propriétés de la couche

  • Dans l’onglet Général, cliquez sur Constructeur de requête pour ouvrir la fenêtre Constructeur de requête.

Cette couche contient trois champs dont nous aurons besoin d’extraire les données qui vont nous servir tout au long de ce manuel.

  • building
  • natural (spécifiquement, l’eau)

  • landuse

You can sample the data your region contains in order to see what kind of results your region will yield. If you find that “landuse” returns no results, then feel free to exclude it.

You’ll need to write filter expressions for each field to extract the data we need. We’ll use the “building” field as an example here:

  • Enter the following expression into the text area: building != "NULL" and click Test to see how many results the query will return. If the number of results is small, you may wish to have a look at the layer’s Attribute Table to see what data OSM has returned for your region:
../../../_images/building_query_builder.png
  • Cliquez sur Ok et vous verrez que tous les objets de la couche qui ne sont pas building ont été supprimés de la carte.

Nous avons maintenant besoin de sauvegarder ce résultat dans une couche shapefile que vous utiliserez tout au long de ce cours:

  • Clic droit sur la couche multipolygons et sélectionnez Sauvegarder sous

  • Assurez-vous de choisir ESRI Shapefile comme type de fichier et sauvegardez le fichier dans votre nouveau dossier exercise_data, à l’intérieur d’un autre dossier nommé epsg4326.

  • Make sure No Symbology is selected (we’ll add symbology as part of the course later on).
  • You can also select Add saved file to map.

Once the buildings layer has been added to the map, you can repeat the process for the natural and landuse fields using the following expressions:

Note

Make sure you clear the previous filter (via the Layer properties dialog) from the multipolygons layer before proceeding with the next filter expression!

  • natural: “natural = ‘water’”
  • landuse: “landuse != ‘NULL’”

Each resulting data set should be saved in the “epsg4326” directory in your new exercise_data directory (i.e. “water”, “landuse”).

You should then extract and save the following fields from the lines and points layers to their corresponding directories:

  • lines: “highway != ‘NULL’” en roads, et “waterway != ‘NULL’” en rivers

  • points: “place != ‘NULL’” en places

Once you have finished extracting the above data, you can remove the multipolygons, lines and points layers.

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

../../../_images/post_osm_import.png

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

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

  • Clic droit sur la couche landuse et sélectionnez Sauvegarder sous

  • Select SpatialLite as the format and save the file as landuse under the “epsg4326” directory.
  • Cliquez sur OK.

  • Delete the landuse.shp and its related files (if created).

2.2. hard Try Yourself Create SRTM DEM tiff Files

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

SRTM DEM can be downloaded from the CGIAR-CGI: http://srtm.csi.cgiar.org/

You’ll need images which cover the entire region you have chosen to use.

Once you have downloaded the required files, they should be saved in the “exercise_data” directory under “raster/SRTM/”.

In Module 6, Lesson 1.2 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 files. 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 images in the example data are:

../../../_images/field_outlines.png ../../../_images/school_area_one.png

2.3. basic Try Yourself Replace Tokens

Having created your localised dataset, the final step is to replace the tokens in the conf.py 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.