Vancouver-Whistler race planning with GRASS and QGIS

From CUOSGwiki
Jump to navigationJump to search


bike routes in Google Earth

The exceptionality about this project is to find a mountain bike route without on-site inspections of the terrain, roads or trails. The only data used for this project is of a digital nature and freely accessible on the web. The goal of this project is to create one of the hardest one day mountain bike-routes in the world. The approach is made through remote sensing of satellite images and digital topographic maps. With the aid of DEM (Digital Elevation Maps) a specific range of total altitude should be accomplished. The interval starts from 3500 meters in altitude to 6000 meters in altitude. Therefore several different routes should be found, in order to provide routes for every difficulty class. Hence the length of the route will vary. As the distance from Vancouver to Whistler on the Highway 1 is 126 km, it is likely that the distance for the different routes will range from at least 140 km to over 200 km. All the different routes will than be used for a mountain bike race, which will take place once a year in the summer, in which the different routes will represent different difficulties. Therefore it is possible that a wide range of people, from amateurs to professionals, from old to young, are able to accomplish the race. The data will be made accessible on the established race homepage, on the homepage of the Province of BC and on the website from BikeGIS in two different types of format:

- gpx format: GPS exchange format used to transfer data on any GPS

- kml format: for visualization on Google Earth, with background information, and pictures about the routes and surroundings

Working Process

In the following a detailed tutorial for all the important steps to realize this project is given.

Data Access

GIS Software

GIS Software captures, calculates, defines and visualizes spatial data. ESRI is one of the leading companys in selling their software ArcGIS. However there is also free available software on the net and two of them are GRASS and Quantum GIS. Download the most recent version of both software providers(GRASS 6.3 and Quantum GIS Version 0.11.0).


For the actual data, we have to ask us the question, which kind of data is necessary to realize this project: Two things will be important

  • a detailed map, with all the existing roads (from minor trails, over logging roads to major streets) to find a scenic but demanding route
  • a digital elevation model to calculate the difference in altitude from the starting point and the finish. But also to calculate slope and indicate dangerous (steep) passages.

Both data can be found on two different internet sites:

  • For DEM: is a federal, provincial and territorial government initiative that is overseen by the Canadian Council on Geomatics (CCOG)

  • For detailed maps: download the required tif raster files (092g, 092j)

WMS Datasets (Updated 2020)

Benefits Of Using WMS

  • QGIS allows the user to utilize WMS datasets, which is quite advantageous for the user in multiple ways. It allows the user access to files that do not need to be downloaded to the users platform, therefore saving the user space on his or her computer. Instead QGIS is linked to the file through a web link. More often than not the files are free to use especially when collecting data from government open data sites. Finally the data provided is usually quite detailed and can be tailored by the user to meet his or her specific needs.

Project Specific Data

  • For this particular project the user will be utilizing data within the province of British Columbia. For this purpose, it is advisable that the user uses the following WMS dataset from open data Canada. ( and ( These WMS files provide the user with an updated DEM of Canada and the CANVEC series (roads, transportation routes, and landmark features). From here the user can zoom to the point of interest (POI), which would be Vancouver/Whistler Canada. This dataset is beneficial for the user as the DEM within the WMS is detailed in a manner that displays the full range of topography and elevation within the project area, making it easier for the user and participants of the race to understand the potential terrain they may encounter during the race.

Working with Grass 6.3 & Quantum GIS

Grass Window

Both Software can be used for this project. However I used more the Grass software for processing and analyzing, and the Quantum GIS software for visualization. Before you even open one of the Software, you should check the coordinate system of each data in the metadata:

  • DEM
  • topographic maps

In this case the projection system of DEM (NAD 1983) is different to the one of the topographic maps (NAD 1983 UTM 10N). This means that the data has to be re-projected, before it can be visualized on the same map. Open Grass 6.3. Two different Locations have to be created (DEM and TOPO). The easiest way is to click on the button "Georeferenced file", and choose one file from the downloaded data (for one Location one file from the DEM data, for the other Location one file from the topographic maps)

In the field "Project Location" two locations should be created now (DEM, topographic map). In each Location mapsets should be created in addition to the Permanent-Mapset (topo-Mapset, dem-Mapset). Import the raster files in each Mapset. It is always very important to adjust the Region extent with the g.region comand , because if the Region extent is too small for the layers, they won't appear in the Map Display window.


Loading WMS in QGIS

  • Firstly, open the open data site on ( The user will notice that the data sets will have a description informing the user on the file content. This will be accompanied by the file and the file format options.
  • Choose WMS format.
  • The user will then be directed to a new tab. From here, the user will copy the link in the website bar.
  • After, open QGIS and open a new project.
  • In the options bar at the top, select "layer", then in the drop down menu click on "Data Source Manager".
  • From here, there should be a new window that has opened in the software. In the menu bar located on the left in this new window select WMS/WMTS.
  • Proceed to select the "New" tab. This will open an additional window which asks for the user to input a new name for the incoming dataset, along with the weblink for the dataset. Simply paste the copied weblink from the open data site, then select the "OK" button.
  • Once complete, check in the layers tab to ensure data has loaded. If the data is not present, ensure the link in the dataset is correct. If it is, then the dataset could be corrupt and in this case contact the content creator from the open data site. Response time should be 24-48 hours. They will provide you with a new link or a shape file.


As we want to use the projection system NAD 1983 UTM 10 N (which is the projection for the topographic maps), the DEM data has to be reprojected to the TOPO-Location. For this process the topo-Mapset (and not the dem-Mapset!!!) has to be opened and with the command r.proj the DEM files can be importet to the TOPO-location.

Patch the Raster files

DEM and topographic maps

You probably realize that you now have a lot of raster files in your Location, which is not only unconvenient because you have to ad each raster file seperatly, which takes a lot of time, they also can't be used in later processes to calculate the elevation for the digitized mountain bike routes. r.patch is the command, where mutliple raster files can be united in one single raster ouput (use only those rasterfiles you really need for the analysis). However you have to make sure, that the region extent is set prior.

  • dem_all
  • topo_all

These two raster files is the only thing you need now for further analysis. It is also possible to patch the raster files, prior to the projection. This however didn't work in my case, probably due to the high amount of transfered data in one process.

The visualization of both data could look like that:

Create Bike-Routes

Now it would be necessary to have a look at both maps (DEM, topo) to try to identify possible routes. Therefore look at areas (e.g. the valleys) without major routes, to see if there are minor roads, which can be used and which don't have a dead end. Take also a look on the web, and see if you can find even more detailed maps, such as hiking maps, which can be available in the different national- or provincial parks, located on the way. One example would be the Garibaldi-Provincial Park. These maps should be taken as a additional visual support in the process of digitization.


digitized routes

with the v.digit command, type

v.digit -n map=route 'bgcmd=d.rast map=topo_all'

in the Ouput window

-n means that you just created the vector with the name route. 'bgcmd=d.rast map=topo_all' means that wou will be able to see the map topo_all in the background, because that is the map you'll need to find the different routes. Even before you start to ditize you have to add a attribute table to the vector map, because otherwise the information you generate by digitizing can not be saved.

v.db.addtable map=route layer=1 'columns=cat integer' 

The attribute table will be saved in your mapset under the directory dbf with the same name as the vector map (therefore route.dbf) and can be opened with Excel.

Now you can start to digitize:

  • click on digitize new line
  • the digit-tool window will get bigger and tells you in which layer (default=1) and in which category it will save the digitized line
  • choose your digitized lines in that way, that on every cross section, where other potential routes can cross you start with a new category (see the green crosses on the map for digitized routes)
  • after digitzigin click on the Save and Exit button

with the command it is already possible to find out how long the different segments are: map=route option=length units=k

k stands for kilometres

Digitizing QGIS Edit 2020

Once the WMS data set has been uploaded to QGIS, the user will then begin the digitizing process in QGIS. The purpose of digitizing for this specific project is so that the user and participants in the bike race can map out their routes from Vancouver to Whistler. This will also allow the participants to see the type of terrain they will encounter along the route, along with identifying key landmarks along the route for ease of navigation during the race.

Digitizing Process QGIS 2020 Update

  • Select "Layer" in the options bar.
  • Then proceed to select "Create Layer" in the drop down menu.
  • Click on "New Shapefile Layer".
  • This will direct user to insert file location and name credentials. The new window will also ask the user to select the "Geometry type". For the the purpose of this project the user will select "Line" as the digitized portion of this project is meant to display the bike route.
  • From this point forward the user will right click on the new shape file and select the "Edit" function. The user can now start digitizing his or her race route.

Creating Shapefile Creating Shapefile Creating Shapefile

Get Elevation data for the Routes

To find out how many meters of altitude each route will be, it is necessary to combine the route-vector map with the dem_all raster map. Therefore the vector map has to be changed from a line vector map to a point vector map.

With the command points will be created along the line vector map: input=route output=points type=line llayer=1 dmax=100 

The resulting points-vector map has to be sampled with the DEM-raster map:

v.sample input=points column=along output=points_z raster=dem_all

column=along is the column with the x,y coordinates. The name can be different, which can be checked by looking up the points.dbf file on excel, which was created automatically during the process.

Calculating the altitude-profile in Excel

points in excel
example of two different routes
  • Open the points_z.dbf file in excel
  • all the points have four different columns:
    • cat: gives you the number from which line this point originates
    • pnt_val: changes with the change of the cat column
    • rast_val: gives you the altidue of each point
    • diff: is the difference between pnt-val and rast-val, but as pnt_val is not 0 all the time, the difference doesn't give the correct values for the elevation of each point
  • three other colums have to be created
    • Height: Difference between tow neighbouring points in altitude
    • Uphill: gives you the positive value from one point to the next one and has to be calculated with the IF-Function, as negative values represent downhill values
      • the formula should look like the following, where the E column is the Height Column, which was just created in the step before: =IF(E2<0;0;E2)
    • Downhill: gives you the negative value from one point to the next one
      • the formula is similar to the Uphill column and should look like that: =IF(E2>0;0;E2)
  • Open Quantum GIS
    • load the route vector map
    • open the attribute table for the route vector map
    • select the rows, which will generate one route from Vancouve to Whistler (see table and the therefore selected lines on the map in the example route)
    • Create new Excel files with the points, belonging to the selected Cat(egory) number in Quantum GIS
      • therefore copy/paste the numbers in the new file (possible name: Route I, Route II, etc.)
    • add a new column=distance in 100 m intervalls, as each point is approximately 100 m from the next one (see the parameter dmax=100)
    • plot the distance over the height to get the profile
    • Sum up the downhill and the uphill values to get total downhill and total uphill

Get Elevation data for the Routes 2021 Update

    • Click the Gear cog icon call "toolbox" in the upperright portion of the tool bar above your map layout
    • In the Search bar on the right side of your screen which should have popped up after you clicked the toolbox search "sample"
    • One of the top 2 searches should be "Sample Raster Values" open that tool
    • then in the Imput field use your points created by "" in the raster layer use your "DEM layer"
    • In the output field name it "DEM Diff" this will show you the difference in elevation from your DEM file.
    • Run File and continue with the remaining steps


Export Data as KML files

KML format is used by Google Earth, which allows the user to visualise the different routes in Google Earth, even in 3D. The problem here is, that the files can't be exported in the TOPO-Location, as the chosen Coordinate System is not a geographic coordinate system (with degrees), which is used by Google Earth. Therefore the routes have to be reprojected to the DEM-Location, as this is a geographic coordinate system. This time the command is v.proj Open the dem-mapset under the DEM-Location and use the following command:

v.out.ogr in=route_1 dsn=route1.kml olayer=route_1 format=KML type=line

the files can now be visualised in Google Earth:

Take Away Points From The 2020 Updates

The 2020 updates to this project tutorial are focused on the use of WMS and digitization within QGIS. The use of WMS for this project is beneficial for the user as it is a time efficient method of obtaining data. It also allows the user to save space on his or her device as the WMS datasets do not need to be stored on the users computer. The digitizing component to this project allows the user to explore the perks of utilizing the digitizing function within QGIS. This function is very user friendly for all levels of users and allows them the freedom to digitize and edit the data effectively. Together the use of WMS and digitizing in QGIS is very beneficial for the users as it will provide them with the tools to create an impressive and effective final product in a time efficient manner.