Reputation: 93
I'm trying to download a gpx file from the YOURS routing API (http://wiki.openstreetmap.org/wiki/YOURS#Routing_API) and upload the file to R using the readGPS function contained in the maptools package.
Here is the code:
require(utils)
require(maptools)
URL <- 'http://www.yournavigation.org/api/1.0/saveas.php?type=gpx&data=5.62373%2053.01,5.62359%2053.01014,5.62336%2053.01024,5.62314%2053.010303'
download.file(URL, 'tmpTrip.gpx')
gpx.raw <- readGPS(i='gpx', f='tmpTrip.gpx', type='t')
And the error I receive:
Error in readGPS(i = "gpx", f = "tmpTrip.gpx", type = "t") :
gpsbabel not found
I do have installed gpsbabel and I can see the gpx file correctly downloaded in my working directory. My system and R version are: Windows 7 Enterprise Service Pack 1, running on Intel Core i5-3320M CPU @ 2.60GHz, 4GB RAM, 32 bit OS.
R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
Any help is much appreciated, thank you!!
Upvotes: 1
Views: 937
Reputation: 814
If you have GPSBabel installed in your working directory as well, this should work.
For me, I changed the WD:
setwd("C:/Program Files (x86)/GPSBabel")
And then my code
gpx.raw <- readGPS(i = "gpx", f = "C:/Users/Desktop/waypoints.gpx", type="w")
worked after that.
Upvotes: 0
Reputation: 625
Figuring it out the hard way, I found that readGPS()
calls Sys.which
which is a function that tries to find where a file is located on the system. ?Sys.which
doesn't say it that clearly but (at least on Windows) for it to work, you need to add the install path of gpsbabel to your path.
Upvotes: 1