read_gpx | R Documentation |
Reads in a GPS Exchange Format XML document and outputs a data.frame
containing distances. The corresponding dates for each track segment
(trkseg
) will be included if present in the source file, else the date
column will be populated with NA
s.
read_gpx(file, units = c("miles", "kilometers"))
file |
The input file to be parsed. |
units |
The units desired for the distance metric. |
Distances are computed using the Haversine formula and do not account for elevation changes.
This function treats the first timestamp of each trkseg
as the date of
record. Thus overnight track segments will all count toward the day in which
the journey began.
A data frame containing up to two columns:
The date of the ride. See description and details.
The distance of the track segment in the requested units.
## Not run:
# Get a list of all GPX export files in a directory tree
gpx_export_files <- list.files(
"/path/to/gpx/exports/",
pattern = "\\.gpx$",
full.names = TRUE,
recursive = TRUE
)
# Read in all files and combine them into a single data frame
rides <- do.call(rbind, lapply(gpx_export_files, read_gpx))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.