[R] track on boats
Michael Sumner
mdsumner at gmail.com
Thu Oct 24 22:57:38 CEST 2013
There are several packages for track data on CRAN and they don't all
force the data to have "specific variables" beyond position,
date-time, track ID. With trip you can do this easily enough, but
depending on your needs adehabitatLT or move might be better. I wrote
trip so I know that you can do this (pseudo code that assumes columns
"X", "Y", "date", "ID" for the obvious components), you get plot
control of separate lines and basic data QC for free (welcome or not):
library(trip)
d <- read.csv("myfile.csv")
## sort out date-times
d$datetime <- as.POSIXct(d$date, [format etc])
## specify the X/Y coordinates (use your relevant column names)
coordinates(d) <- c("X", "Y")
## create trip object
tr <- trip(d, c("datetime", "ID"))
(If your data are out of order by ID,time or if there are duplicates
or missing values or other problems that will complain and not make
assumptions, but these are things that should be dealt with explicitly
IMO.)
## then you can plot the separate tracks in a minimal way
plot(tr)
lines(tr)
There is general support for reading and manipulating spatial data
with packages sp, raster, maptools and friends. See the "Spatial" and
"SpatioTemporal" Task Views, and consider R-Sig-Geo rather than R-help
for questions like this. I agree that "Animal Tracking" is too
specific for your needs, but there's certainly room for generalizing
this to other domains easily enough. The trip package is too simple
and awkward for many things, but for basic use there's no built-in
assumptions that track data are from animals (though the label on the
lid does specify that).
HTH
On Fri, Oct 25, 2013 at 3:08 AM, Adams, Jean <jvadams at usgs.gov> wrote:
> It is difficult to advise you when you don't provide reproducible data.
> For example, you could include the first 6 lines of your data using
> dput(head(mydata))
>
> If you have GPS points stored as easting, northing, and if you have a
> variable that identifies the vessel, and if your data are sorted by date
> and time, then you might be able to get the plot you want using something
> like this:
>
> plot(easting[vessel="This One"], northing[vessel="This One"], type="l")
>
> Jean
>
>
> On Thu, Oct 24, 2013 at 4:40 AM, Marta Tobeña <marta_mtm at hotmail.com> wrote:
>
>> Hi professors
>> I'm finding the best package in R for manage a big database about vessels.
>> I need to divided the travel of each boat into tracks. I have GPS points.
>>
>> I would join these points in a line on the map. I make that with the
>> function "lines", but I can't divided by vessel or by track,
>>
>> I saw several packages, for tracking animals but they had specifically
>> variables. And I don't add others like "type","destination" or "status".
>>
>> Can you give me a suggestion, please
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com
More information about the R-help
mailing list