[R-sig-Geo] upload waypoint data to Garmin GPS
Patrick Giraudoux
patrick.giraudoux at univ-fcomte.fr
Mon Nov 17 17:57:36 CET 2008
James Nylen a écrit :
> The easiest thing to do is probably to write the data.frame to a
> tab-delimited text file using write.table and then read in the written
> file like you have done above. See ?write.table - as I recall there
> are plenty of options that will allow you to specify the separator,
> whether or not to write headings, etc.
>
> -James
This is exactly what I did yesterday (see script below - the function
uploadEtrex is now at the working stage in a package pgirbirc at
http://pagesperso-orange.fr/giraudoux/ or
http://pagesperso-orange.fr/giraudoux/#pgirbric)
However when I think about it, my question was a bit silly: it was
something as how to send a r-object to a connexion that a batch script
could read at the operating system level without writing a file on
disk... I guess there is no solution and the easiest way, indeed, is to
write a text file and make it read from the shell (which is what the
current fonction does...).
Thanks anyway for your input,
Patrick
uploadEtrex <- function (df, wcom = 4)
{
dff <- as.data.frame(matrix(NA, nrow = nrow(df), ncol = 9))
dff[, c(2, 8, 9)] <- df[, c(1, 3, 2)]
write.table(dff, "dff", col.names = FALSE, sep = "\t", quote = FALSE)
if (Sys.info()["sysname"] != "Windows") {
system(paste("gpsbabel -w -i tabsep -f dff -o garmin -F
/dev/ttyUSB0",
sep = ""))
}
else {
system(paste("gpsbabel -w -i tabsep -f dff -o garmin -F com",
wcom, ":", sep = ""))
}
}
>
>
>
> On 11/16/08, *Patrick Giraudoux* <patrick.giraudoux at univ-fcomte.fr
> <mailto:patrick.giraudoux at univ-fcomte.fr>> wrote:
>
> Dear listers,
>
> I am writing a R function to upload waypoints to a GPS Garmin
> Etrex with gpsbabel. This works quite well reading from a text
> file as following:
>
> df<-"mytabfile.txt"
> system(paste("gpsbabel -w -i tabsep -f ",df," -o garmin -F
> com5:",sep=""))
>
> However, I would prefer to upload from a data.frame within R
> rather than reading a tab delimited text file on the disk.
>
> Any idea about how to specify it in the command line (should be
> trivial, but I cannot figure it out) ?
>
> Thanks in advance,
>
> Patrick
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch <mailto:R-sig-Geo at stat.math.ethz.ch>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20081117/bee6c0fd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patrick_giraudoux.vcf
Type: text/x-vcard
Size: 399 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20081117/bee6c0fd/attachment.vcf>
More information about the R-sig-Geo
mailing list