Package 'gpx3d'

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

Help Index


Extract A Dataframe From A GPX File

Description

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.

Usage

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.

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.

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.

Examples

## Not run: extract_gpx3d(gfx_segment)

A Workout Route Segment

Description

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.

Usage

gpx_segment

Format

An sf-class data.frame with 501 features and 5 fields:

time

datetime

ele

elevation (metres)

lon

longitude

lat

latitude

geomatry

sf-class POINT geometry of lon-lat

distance

units (metres), distance between this point and the previous


Render A 3D Plot Of A Route From A GPX File

Description

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.

Usage

plot_gpx3d(route_df, route_only = FALSE)

Arguments

route_df

A data.frame, optionally sf-class. Output from must be in the format output via extract_gpx3d.

route_only

Logical. Retain all chart elements if FALSE (default) or retain only the route path if FALSE.

Value

An interactive 3D rendering of the route path in a devoutrgl device.

Examples

## Not run: 
x <- extract_gpx3d(gfx_segment)
plot_gpx3d(y)

## End(Not run)