I started off with a SpatialPointsDataFrame, containing locations from animals wearing GPS loggers. Aside from the coordinates, the data frame also contains the animals' ID and a timestamp.
From this SpatialPointsDataFrame, I created lines that show the trajectory of each animal over the tracking period. I've used the following code:
spdf4tri
#the SpatialPointsDataFrame
ids=unique(spdf4tri$id)
trajectory <- list()
for (i in ids){
spdf4bird<-subset(spdf4tri, id==i)
birdtrajectory<-SpatialLines(list(Lines(list(Line(spdf4bird)), "id")))
trajectory[[i]]<-birdtrajectory
print(i)
}
Now, I have a problem, because trajectory
is of the class 'list'. I cannot figure out how to unlist it.