Mosaicing & Projecting
Clipping DEM to locations
Note: Elevation units are in meters.
Note: everything is in metric because we are doing science!
Mosaicing & Projecting
Clipping DEM to locations
Note: Elevation units are in meters.
We’ll look at an activity recorded on an Apple watch, and use two sources for elevation:
Note that while the DEM is quite accurate, it will necessarily flatten features smaller than 10m, and it depends on the accuracy of the horizontal (X, Y) coordinates.
The altimeter data reported a consistently higher value, but traces quite well.
Let’s zoom in a bit to a half kilometer traveled so we can see the different structure of the elevation data sources. You can see the “steps” in the DEM data as you cross from one tile to another, while the altimeter data is recorded frequently enough that it appears smooth (this is directly from the GPX and has not been smoothed beyond what happened on-device).
Warning: Removed 25584 rows containing missing values or values outside the scale range
(`geom_line()`).
Did the relationship between the two change over time? We can plot the “error” ( in quotes, because neither of these values are the truth)
of predicting the DEM from the altimeter over time, and while we can see that the relationship between the two clearly wobbles over short time periods, it’s stable overall: the DEM averages about 1.01 times the altimeter reading, minus 24 meters.
`geom_smooth()` using formula = 'y ~ x'
If we simply add up each increase in elevation over the track, we get the following:
| Source | Cumulative Elevation Gain |
|---|---|
| DEM | 1452 |
| raw | 856 |
Clearly, neither of these are what we expect. We are counting every little jitter in the elevation data as a gain, which results in even the DEM-sourced gain being inflated. Is that “correct”? Up to you, but unless you want your jaunty bouncy walk to count for twice as much elevation as your friend’s steady careful walk (or realistically, your noisy altimeter to count for twice as much elevation as their precise one), we need to dull out the small, randomish gains in elevation.
We can smooth the z-axis (elevation) of the path using a spline (credit to https://github.com/trackerproject/trackeR).
| Source | Cumulative Elevation Gain Smoothed |
|---|---|
| DEM | 762 |
| raw | 757 |
Now the numbers agree a little better with each other! But we still have two numbers.
We could go a step further and fit the altimeter values to the DEM values (as we did before to see if there was a pattern in the “error”).
That ties the altimeter readings to the “ground truth” of the DEM readings, but preserves the small scale variation that the altimeter sees while traversing a single grid cell in the DEM (which will look flat or stepped). Then we can smooth that fitted value to get an elevation gain that incorporates both sets of data while ignoring noise in the ups and downs.
| Cumulative Elevation Gain Smoothed & Adjusted |
|---|
| 767 |