Using data from our mobile phones, raster and vector data

We are going to look at some GPX data (the type that comes of your phone when collecting tracks and waypoints using GPSLogger and OpenGPX. We will then take it into QGIS and ArcPro to do some analysis with it.

GPX Files

A GPX file is the standard file for sharing information from devices (GPS/GNSS device) or mobile apps. It is a XML based file format that records a point location at a certain interval – time based or distance based. Here is an example of the GPX file we will be playing with this week.

The top of the file:
Click the image for a larger view

End of the file:

As you can see the text in the file (much like we saw with the Postalcode text file) will create a system of points than can be joined to create lines. In fact for this lab, Scott has taken the line from the first track point:

<trkpt lat="53.89354394" lon="-122.82148698"><ele>779.975</ele><time>2020-08-20T22:46:10Z</time><speed>0.000</speed><sat>13</sat></trkpt>

and pasted it to the end of the file and saved it as a new file (we will see this in the lab), so a polygon can be created from the file.

Adding a GPX file to software

We are at the point whereby we want to use the software that makes life the easiest. ArcPro can read GPX files, but you need to use a processing tool – QGIS just opens the file (so we will use QGIS this week).


  • Open QGIS
  • Add in the GPX files in L:\GEOG204\lab6 folder (you can drag and drop
  • Select the track points and tracks only for each dataset
  • You will end up with two sets of data with the same name in the TOC, but you can tell them apart by the completeness of the track lines and the extra point in the “poly” file
  • Add in a web map background to see where the data is located – the ESRI Topo layer provides a nice view of the terrain

Investigate the data

You can see from looking at the data, we lost satellite reception often in our walk, but there are plenty of places to check out data under the track points. You can also see there are elevation values collected from the GNSS app in Scott’s phone. Lets compare it with a DEM from 2018 LiDAR data.

DEM data with point data

Sample raster data

  • Add in the scott_roger_explore_dem layers into the project (Drag and Drop or Layer –> add Raster Layer
  • Find the sample raster values in the processing toolbox
  • Fill out the panel appropriately – it does not matter which point layer you use as they are the same data
  • You can make an temporary file if you like
  • Look at the new layers table and note the column name that was added

Do some math

  • Open the attribute table of the new layer
  • Use the calculator to create a new column that computes the difference between the GPX elevation compared to the LiDAR DEM data
  • Style the layer to see the differences

What kind of range do you get for the differences – quite the error in elevation values mobile phone GNSS data collectors provide!

Clean up your GPX data

  • Right click on the sampled and calculated layer –> properties
  • Select the Fields tab in the panel
  • Ensure the layer is in edit mode
  • Select all the fields you are not interested in keeping (most of them probably)
  • Hit the delete field button to remove the fields
  • Turn off the edit mode – turn off the pencil
  • Close the properties panel

Export as a new file type

Export the data in the usual fashion with the following requirements:

  • Export as a GEOPACKAGE
  • Export the data in the local UTM projection (EPSG: 26910)
  • Call the layer whatever you wish
  • When the data is loaded into the canvas copy the style from the original dataset
  • Right Click on the old dataset –> style –> copy –> symbology
  • Right Click the new geopackage — stlye —> paste –> symbology
  • Save the style with the layer –> properties of geopackage –> symbology
  • Save –> In database –> give the style a name and description

Create a polygon and get some statistics

Using the GPX layer that has the potential to be made into a polygon (scott_roger_explore.gpx), create a polygon layers.

Once that is completed, sample under the polygon to get elevation and slope data.

Here are some suggested steps:

  • Create a polygons from the track layer as you did in lab 2
  • Create a slope layer as you did in lab 5 or check see if you can do so in QGIS – it is so very simple
  • Sample under the polygon using the zonal statistics tool with the following parameters
  • include count, min, max, Standard Deviation, mean
  • use the prefix “dem_” for the DEM sampling and “slope_” for the slope layer (in other words sample both the DEM and the Slope layer)
  • Check out the sample image below

Clean up the unnecessary attribute fields and save this as a second geopackage (no need to worry about styling)

Check against the track points

Check the elevation differences you sampled with the point data (where Scott and Roger walked)

  • Find the Basic Statistics for fields tool
  • Run this on the geopackage dataset for the sampled points using the LiDAR elevation values as the field to calculate the statistics
  • The report will be generated in the log pane
  • How do the min, max and mean values compare to those calculated in the area by the zonal statistics from the polygon layer and DEM values?

New project and assignment

Save your project and start a new project

Adding a DEM layer for Prince George

We are going to add a DEM layer for Prince George and test it against a trail layer. We first need to determine which DEM to use for Prince George

Determine the mapsheet number

  • Add the 250k_sheets_albers shape file from L:\DATA\250K_mapsheets_BC
  • Set the projection of your canvas to UTM Zone 10 (26910). This is not necessary, but it is helpful
  • Add in a web map (OSM standard)
  • Set the transparency of 250K layer to enable viewing of Prince George
  • If it takes awhile for OSM to load, zoom in a bit toward Prince George
  • Determine the mapsheet we will need to use
  • You can find the name of the 250K mapsheet from its attributes (A250K_TAG) from the polygon that Prince George is in)
  • You should find the value 093G

Grabbing the DEM to match this mapsheet

  • Find the zip file containing the proper DEM from the mapsheet value in L:\DATA\dem25m_utm
  • Unzip this file to your K drive (or you can use the unzipped one in this week’s lab folder)
  • You should have two files unzippped: 93g-dem25m-utm10.asc and 93g-dem25m-utm10.prj
  • Drag the .asc file into QGIS
  • Also add the Trails layer from: L:\GEOG204\lab6 to the canvas
  • Remove the 250K layer

Clean up the trails

You can see all the trails except Ferguson Lake (north of the DEM) fit on the DEM. Remove this trail loop by:

  • Save the Trails layer to your K drive as a geopackage
  • Edit the layer –> remove the loop
  • Save your edits


We will be reviewing the assignment in Lecture this week, but in order to make the semester a bit easier, we are going to make this assignment out of 10 (lowering the value of the project or the final exam or substituting a smaller assignment instead of a lab quiz) and it will be due Monday November 16.

Description of Assignment

We want to see the difference between using a couple tools for determining how difficult a trail may be to walk compared to checking points along a line sampled against a slope layer. You will carry out this check using the following steps:

  • Use the drape tool to get elevation values “Z” values from a DEM to create a 3D line layer. Use your trail layer to initiate the process
  • Use the Climb Along Line tool to generate some climbing attribute for this layer
  • Create a new line layer by using the densify by interval tool with a 20 metre spacing using your trail layer as input.
  • Create a new point layer by extracting these new vertices created from the densified line using the extract vertices tool
  • Create a slope layer from the DEM
  • Sample the new point layer against the slope layer
  • Style the climb layer and the sampled point layer as graduated using the same colour scheme with the same number of classes

For your write up, describe the steps you took to get your results, and create screenshots of your two resultant layers against the slope layer as a base layer.

Below is an example of this type of output:

Categories: GEOG 204Labs