read_container: Read a GPS container file.

View source: R/reading.R

read_containerR Documentation

Read a GPS container file.

Description

Read a GPS container file.

Usage

read_container(
  file,
  type = c("tcx", "gpx", "db3", "json"),
  table = "gps_data",
  timezone = "",
  session_threshold = 2,
  correct_distances = FALSE,
  smooth_elevation_gain = TRUE,
  country = NULL,
  mask = TRUE,
  from_distances = NULL,
  speedunit = NULL,
  distanceunit = NULL,
  sport = NULL,
  lgap = 30,
  lskip = 5,
  m = 11,
  silent = FALSE
)

readContainer(
  file,
  type = c("tcx", "gpx", "db3", "json"),
  table = "gps_data",
  timezone = "",
  session_threshold = 2,
  correct_distances = FALSE,
  smooth_elevation_gain = TRUE,
  country = NULL,
  mask = TRUE,
  from_distances = NULL,
  speedunit = NULL,
  distanceunit = NULL,
  sport = NULL,
  lgap = 30,
  lskip = 5,
  m = 11,
  silent = FALSE
)

Arguments

file

The path to a tcx, gpx, json or db3 file. Compressed versions (gz, bz2, xz, zip) of tcx, gpx, and json files are directly supported.

type

The type of the GPS container file. Supported so far are tcx, db3, and json.

table

The name of the table in the database if type is set to db3, ignored otherwise.

timezone

The timezone of the observations as passed on to as.POSIXct. Ignored for JSON files.

session_threshold

The threshold in hours for the time difference between consecutive timestamps above which they are considered to belong to different training sessions.

correct_distances

Logical. Should the distances be corrected for elevation? Default is FALSE.

smooth_elevation_gain

Logical. Should the elevation gain be smoothed before computing elevation gain? Default is TRUE.

country

ISO3 country code for downloading altitude data. If NULL, country is derived from longitude and latitude

mask

Logical. Passed on to getData. Should only the altitudes for the specified country be extracted (TRUE) or also those for the neighbouring countries (FALSE)?

from_distances

Logical. Should the speeds be calculated from the distance recordings instead of taken from the speed recordings directly. Defaults to TRUE for tcx and Golden Cheetah's json files and to FALSE for db3 files.

speedunit

Character string indicating the measurement unit of the speeds in the container file to be converted into meters per second. Default is m_per_s when type is tcx and km_per_h when type is db3 or json. See Details.

distanceunit

Character string indicating the measurement unit of the distance in the container file to be converted into meters. Default is m when type is tcx and km when type is db3 or json. See Details.

sport

What sport does file contain data from? Either 'cycling', 'running', 'swimming' or NULL (default), in which case the sport is directly obtained from the readX extractors.

lgap

Time in seconds corresponding to the minimal sampling rate.

lskip

Time in seconds between the last observation before a small break and the first imputed speed or the last imputed speed and the first observation after a small break.

m

Number of imputed observations in each small break.

silent

Logical. Should warnings be generated if any of the sanity checks on the data are triggered?

Details

Available options for speedunit currently are km_per_h, m_per_s, mi_per_h, ft_per_min and ft_per_s. Available options for distanceunit currently are km, m, mi and ft.

read_container try to identify the sport from the data in the container file. If that fails, then an attempt is made to guess the sport from keywords in the filename. If identification is not possible then an error is returned from trackeRdata. To avoid that error, and if the sport is known, append an appropriate keyword to the filename (e.g. 'ride', 'swim', 'run'). This should fix the error.

Value

An object of class trackeRdata.

See Also

trackeRdata, readTCX, readDB3, readJSON

Examples

filepath <- system.file("extdata/tcx", "2013-06-08-090442.TCX.gz", package = "trackeR")
run <- read_container(filepath, type = "tcx", timezone = "GMT")

trackeR documentation built on May 29, 2024, 5:04 a.m.