read_gpx {eddington} | R Documentation |
Read a GPX file into a data frame containing dates and distances
Description
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.
Usage
read_gpx(file, units = c("miles", "kilometers"))
Arguments
file |
The input file to be parsed. |
units |
The units desired for the distance metric. |
Details
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.
Value
A data frame containing up to two columns:
- date
The date of the ride. See description and details.
- distance
The distance of the track segment in the requested units.
Examples
## 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)
[Package eddington version 4.1.3 Index]