Often, one may have a data frame of locations with attributes such as species names and may wish to create a GPX file from this data to use with a navigation software such as a GPS device. This can be achieved in four steps as follows:
# Load R library and dataframe
library(terra)
x <- data.frame(NAME=c("Species1", "Species2", "Species3"),
LAT=c(70.11, 70.032145, 68.619535),
LON=c(-148.52, -148.640821, -149.556137))
head(x)
# Create a spatial vector from the dataframe
v <- vect(x, geom=c("LON", "LAT"), crs="+proj=longlat +datum=WGS84")
# Write the spatial vector to file in GPX format
writeVector(v, "~/GPS_waypoints.gpx", filetype="GPX", layer="waypoints",
overwrite=TRUE, options="GPX_USE_EXTENSIONS=yes")
Connect your GPS device to a computer, and drag and drop the new file in the GPX folder of your GPS device. That's it!