gpx: Create a GPX (GPS Exchange Format) output.

View source: R/gpx.R

gpxR Documentation

Create a GPX (GPS Exchange Format) output.

Description

gpx creates XML output in the GPX format (GPS Exchange Format) from latitude, longitude and time.

Usage

gpx(lat, lon, time, file = NULL)

Arguments

lat

latitude of the points

lon

longitude of the points

time

time of the points (optional)

file

destination - can be a character string naming the output file or a connection to use for output or NULL in which case the function return a character vector with teh output.

Details

The resulting output is in GPX format contining exactly one track with the specified values (NAs are currently not supported!). If the time value is present then the track entries will include a time nodes as well. No checking is done on time entries so the user must ensure that they are exactly of the form YYYY-MM-DD HH:MM:SS, assumed to be in UTC.

(Note that OSM requires time stamps to be present in uploaded tracks.)

Value

If file is NULL then the value is a character vector containing the lines of the GPX output.

Examples

lat <- c(40.779, 40.777)
lon <- c(-74.428,-74.418)
cat(gpx(lat, lon), sep='\n')
cat(gpx(lat, lon, Sys.time()), sep='\n')

s-u/snippets documentation built on June 29, 2022, 6:42 a.m.