Topics for today

We are going to get started on the last lab/tutorial project for the semester by combining your gpx data downloaded from your mobile phones Open Street Map data.

We then are going to work with the GPX data we used in lab last week to test our methods for our assignments

Getting data for your GPX assignment

Although we are not all in Prince George attending classes in the GIS Lab, we can all obtain data to use with our GPX assignment. As Open Street Map (OSM) data is globally collected and shared, we can grab all sorts of data to work with.

Install a new plugin

Just as you have before, install a new plugin called QuickOSM.

Setup you study area

Once the plugin is installed, we will load the data from last week and setup our map

  • Load the scott_roger_explore gpx file from the L:\GEOG204\lab6 folder
  • Load the OSM standard web tile from the QuickMapService plugin (web –> QuickMapService –> OSM –> OSM Standard
  • Set you area up to cover the GPX data, some water features, UNBC and a bit of Prince George:

Pull down OSM data for this extent

We can get some vector data for this area by using the newly installed QuickOSM plugin

  • Under the vector menu –> QuickOSM
  • We only need to use the quick query tab
  • Select the canvas extent in the spatial extent drop down
  • Hit “Run Query” – bottom right

Rename layers in preparation for saving to a geopackage

You should now have a bunch of data called “Allkeys“. We should rename these layers to better understand what they represent.

Line layers

Check out the attributes of the two lines to determine which line layers has only major lines (less number of features). Rename this layer as “major_lines“. Repeat this for the other line layer, but name it “all_lines

Point layer

Name the point layers “poi” (points of interests)

Polygon layer

Name the polygon layers “osm_areas

Using a single geopackage

We want to add all the layers we downloaded from OSM into a single geopackage. This is a bit tricky, but simple once you have the hang of it

Add you first layer

  • Right click the polygon layer (osm_areas) and set up an export to a geopackage
  • Name you new geopackage file as “osm_layers.gpkg
  • Name you layer osm_areas (we can have more than one layers in a geopackage)

Add more layers to the geopackage

We are now going to play around a bit with the DB Manager in QGIS to add more layers to the geopackage

  • Open DB Manager by finding it under the database menu
  • Right click on Geopackage
  • Select new connection
  • Select the osm_layers.gkpg file
  • You should see you geopacakge file in the tree
  • Expand the tree to see you database
  • Highlight this database (
  • Click Import Vector/File
  • Select the major_lines layer from the pulldown select
  • Name the layer major_lines (it should be the default)
  • Hit OK
  • Repeat this for the remaining two layers

Congratulations – you are a spatial database manager.. well getting there at least. When you are finished, you should have four layers in your geopackage.

Setup your workspace

Remove all you layers in your TOC except the tracks, track points and OSM base map (web tile).

You can now add in the layers from the geopackage:

  • Open the DB Manager
  • Select a layer from your geopackage
  • Right click
  • Add to the canvas
  • Repeat for all four layers



As part of the assignment, you will need to add your GPX to the canvas and carry out some analysis (a couple simple tasks).

1.) Bring you GPX data into QGIS. Save your tracks, track points and waypoints to a geopackage

2.) Download some OSM data for the area around your GPX data

3.) Determine the nearest POI to either a track line, track point or a waypoint ( the best would be a waypoint). You will use the “Distance to Nearest Hub“). We will test that below

4.) Find the closest point in the osm POI layer (point layer) from this analysis and save this point to a new layer in the geopackage you created in task 1.

5.) Select the OSM polygons that intersect your track line(s) – HINT: use select by location

6.) Save the polygons that were selected to your geopackage.

You can save your OSM data to a geopackage if you prefer (it is much safer that using the temporary layers created when you download the layers using QuickOSM), but you are not required to do this tranlation

Write up

Detail the steps (describe what you did) you took to complete the 6 tasks above in word (or equivalent). Include screenshots if that helps.

Email your write up and your geopackage to your TA for grading at the end your tutorial the week of November 23.

Using Distance to nearest hub

This is a simple little tool that finds the nearest feature in another layer to each feature in a chosen layer. As part of the results, the function adds the distance and and attribute value the of the closest feature to the chosen layers attribute table.

Test it out with today’s data:

  • Open the tool from the processing toolbox
  • Choose the points (poi) layer from OSM (our poi layer in the geopackage) as source layer
  • Select the scott_roger_explore track points as the destination hubs layer
  • Select the “fid” as the hub layer attribute
  • Use meters (metres) as the distance measurement
  • Hit Run