Title: | 3D Plot A Route From A GPX File |
---|---|
Description: | Extract a data from a GPX file into a an sf-class dataframe, then plot a 3D rendering of the route. Designed with workout-route data from the Apple Health app in mind. |
Authors: | Matt Dray [aut, cre] |
Maintainer: | Matt Dray <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9002 |
Built: | 2025-01-14 03:07:41 UTC |
Source: | https://github.com/matt-dray/gpx3d |
Takes a .gpx file as input and extracts the date, time, latitude, longitude and elevation data to a data.frame. Geometry and point distances are calculated with coercion to sf-class. Designed for use with .gpx files downloaded from the Apple Health app, which represent individual workouts.
extract_gpx3d(gpx_file, sf_out = TRUE)
extract_gpx3d(gpx_file, sf_out = TRUE)
gpx_file |
Character. Path to a valid .gpx file. |
sf_out |
Logical. Retain sf-class in output (defaults to TRUE), or output as a data.frame only (FALSE)? Package sf is used within the function to calculate distance between points. |
The function usess the sf package to create a 'geometry' column
from which distances can be generated between points along the route. You
may want to retain the sf class for further geospatial analysis,
otherwise you can output a regular data.frame with sf_out = FALSE
,
which strips the sf metadata and the 'geometry' column.
A data.frame, sf-class by default, with columns 'time' (datetime),
'ele' (double), 'lon' (double), 'lat' (double) and 'distance'
(units, metres); 'geometry' (POINT) if sf-class is retained with
sf_out = TRUE
.
## Not run: extract_gpx3d(gfx_segment)
## Not run: extract_gpx3d(gfx_segment)
An sf-class data.frame with a row per point recorded along a workout route,
originally exported as a gpx file from Apple Health and with data exported
by the extract_gpx3d
function.
gpx_segment
gpx_segment
An sf-class data.frame with 501 features and 5 fields:
datetime
elevation (metres)
longitude
latitude
sf-class POINT geometry of lon-lat
units (metres), distance between this point and the previous
Create a ggplot2 plot object with a third dimension thanks to ggrgl. The x and y coordinates are the longitude and latitude, the z dimension is the elevation along the route. The chart title includes the total distance, elevation disparity, plus the date and start/end times.
plot_gpx3d(route_df, route_only = FALSE)
plot_gpx3d(route_df, route_only = FALSE)
route_df |
A data.frame, optionally sf-class. Output from must be in the
format output via |
route_only |
Logical. Retain all chart elements if |
An interactive 3D rendering of the route path in a devoutrgl device.
## Not run: x <- extract_gpx3d(gfx_segment) plot_gpx3d(y) ## End(Not run)
## Not run: x <- extract_gpx3d(gfx_segment) plot_gpx3d(y) ## End(Not run)