readGPS: GPSbabel read interface

View source: R/readGPS.R

readGPSR Documentation

GPSbabel read interface


The function reads a data frame from an attached GPS using the external program gpsbabel. The columns of the data frame need to be identified by hand because different GPS order NMEA data in different ways, and the columns should be converted to the correct classes by hand. Once the specifics of a particular GPS are identified, and ways of cleaning erroneous locations are found, the conversion of the output data frame into a usable one may be automated.


readGPS(i = "garmin", f = "usb:", type="w", invisible=TRUE, ...)



INTYPE: a supported file type, default "garmin"


INFILE: the appropriate device interface, default "usb:", on Windows for serial interfaces commonly "com4:" or similar


"w" waypoints, or "t" track, or others provided in gpsbabel


Under Windows, do not open an extra window


arguments passed through to read.table


The function just wraps: gpsbabel -i INTYPE -f INFILE -o tabsep -F - in system(), and reads the returned character vector of lines into a data frame. On some systems, INFILE may not be readable by ordinary users without extra configuration. The gpsbabel program must be present and on the user's PATH for the function to work. Typically, for a given GPS, the user will have to experiment first to find a set of data-cleaning tricks that work, but from then on they should be repeatable.


A data frame of waypoint values


Patrick Giraudoux and Roger Bivand



## Not run: 
#b1 <- readGPS(f="usb:")
#b2 <- b1[1:172,]
#wp0 <- b2[,c(2,3,4,8,9,19)]
#wp0$long <- wp0$V9
#wp0$lat <- as.numeric(as.character(wp0$V8))
#wp0$id <- as.character(wp0$V2)
#wp0$alt <- as.numeric(substring(as.character(wp0$V19), 1,
# (nchar(as.character(wp0$V19))-1)))
#wp0$time <- as.POSIXct(strptime(paste(as.character(wp0$V3),
# as.character(wp0$V4)), format="%d-%b-%y %H:%M:%S"))
#wp1 <- wp0[,-(1:6)]

## End(Not run)

maptools documentation built on Oct. 21, 2022, 5:09 p.m.