gpx.Rd
gpx
creates XML output in the GPX format (GPS Exchange Format)
from latitude, longitude and time.
gpx(lat, lon, time, file = NULL)
The resulting output is in GPX format contining exactly one track with
the specified values (NA
s 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.)
If file
is NULL
then the value is a character vector
containing the lines of the GPX output.
lat <- c(40.779, 40.777)
lon <- c(-74.428,-74.418)
cat(gpx(lat, lon), sep='\n')
#> <gpx version="1.1" creator="R">
#> <trk>
#> <trkseg>
#> <trkpt lat="40.779" lon="-74.428" />
#> <trkpt lat="40.777" lon="-74.418" />
#> </trkseg>
#> </trk>
#> </gpx>
cat(gpx(lat, lon, Sys.time()), sep='\n')
#> <gpx version="1.1" creator="R">
#> <trk>
#> <trkseg>
#> <trkpt lat="40.779" lon="-74.428"><time>2024-09-26T03:28:21.499964Z</time></trkpt>
#> <trkpt lat="40.777" lon="-74.418"><time>2024-09-26T03:28:21.499964Z</time></trkpt>
#> </trkseg>
#> </trk>
#> </gpx>