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)

Arguments

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.

Value

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.

Details

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.

Examples

if (FALSE) extract_gpx3d(gfx_segment)