[R-sig-Geo] reading a gps from R

Roger Bivand Roger.Bivand at nhh.no
Sun Jan 14 18:27:49 CET 2007


Patrick,

On Sun, 14 Jan 2007, Patrick Giraudoux wrote:

> Sorry to answer to myself. I have found a solution for the 2nd question: 
> from R within windows the gps can be read with:
> 
> shell("gpsbabel -w -i garmin -f com4: -o openoffice -F \"wpt.txt\"")
> 

Good.

> The 1th question about reading the gps data directly to an R object 
> unstead of a text file is still unanswered...
> 

Since the files are not too large, would pasting an R temporary file into 
the system call, and then reading from it be a fix? I've tried "-" as the 
file name under Linux, and it does return the data to stdout (terminal 
screen), but I haven't got any further because on RedHat EL 4 I can't see 
how to use gpsbabel without being administrator (I've tried both the FC 
tips on the gpsbabel website with no effect). system(intern=TRUE) should 
grab that output:

wps <- system("gpsbabel -w -i garmin -f usb: -o tabsep -F -", intern=TRUE)
wps_df <- read.table(textConnection(wps), fill=TRUE)

but there is a lot of unneeded information there. Could the xcsv format be 
used with a suitable style?

Best wishes,

Roger


> Cheers,
> 
> Patrick
> 
> 
> 
> Patrick Giraudoux a écrit :
> > Dear Listers,
> >
> > I am trying to write R fonctions to read data from a gps through 
> > gpsbabel.
> >
> > Within linux I have tried this (read garmin gps and write a tab 
> > delimited text file wp.txt) and it works well:
> >
> > system("gpsbabel -w -i garmin -o openoffice /dev/ttyUSB0 
> > /home/giraudoux/wp.txt")
> >
> > I have two questions:
> >
> > 1/ I wonder whether it would be technically possible to open the 
> > connexion directly to a R object (eg data.frame) rather than to write 
> > a text file (here wp.txt) ?
> >
> > 2/ I wonder how to open a USB device/port within a windows XP 
> > environment (linux equivalent of /dev/ttyUSB0).
> >
> > Thanks in advance for any hint...
> >
> > Patrick
> >
> >
> >
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list