Hi,

I have a csv containing animal movement data which is broken into different 
behavioral classes (under the heading line_id). I want to plot each of the 
trajectories as a spatial line segment. I am trying to do this in a loop, but I 
am running in to problems creating a list of Line objects. I need this list of 
Line objects to then create an object of Lines, which is then used to create 
spatial lines. The exact error message I get when I try to run the Lines 
command is: Error in Lines(l) : slinelist not a list of Line objects
I'm not sure how utilize a loop to continually add to the list and maintain the 
correct structure  of the list.

This is the script of the code I have started:

lid <- read.csv("Jackal Trajectory with line ID.csv", header=TRUE, sep=",")
c<-lid[1,]
x1<-lid$x
x<-x1[1:2]
y1<-lid$y
y<-y1[1:2]
l<-Line(cbind(x, y))

for(i in 1:max(lid$Line_id))
{
  c<-subset(lid, Line_id==i)
  x<-c$x
  y<-c$y
  xy<-cbind(x,y)
  cl<-Line(xy)
  class(cl)
  l<-list(l, cl)
  class(l)
  L<-Lines(l)
  c <-lid[j+1,]
}

This is what the header of lid looks like:
X X.2 X.1      x       y           date         dx         dy      dist   dt    
     R2n abs.angle  rel.angle       id
1 1   2   2 812570 1483774 1/23/2011 3:30    2.99422   10.00079  10.43940 1800  
  74.10397  1.279892  1.8997337 Jackal 1
2 2   3   3 812573 1483784 1/23/2011 4:00   12.99851  -27.00043  29.96639 1800  
 125.02478 -1.122124 -2.4020154 Jackal 1
3 3   4   4 812586 1483757 1/23/2011 4:30 -133.99022  -18.00047 135.19392 1800  
1012.99858 -3.008051 -1.8859266 Jackal 1
4 4   5   5 812452 1483739 1/23/2011 5:00  -68.00605   33.00061  75.59010 1800 
13918.96053  2.689806 -0.5853283 Jackal 1
5 5   6   6 812384 1483772 1/23/2011 5:30  -81.00085 -124.99994 148.95007 1800 
32088.77982 -2.145769  1.4476096 Jackal 1
6 6   7   7 812303 1483647 1/23/2011 6:00 -107.99594  112.00003 155.58641 1800 
85022.69403  2.337996 -1.7994203 Jackal 1
     burst pkey cluster.kl.j kmeansj convert.j Line_id
1 Jackal 1    2            1       1 108.84672       1
2 Jackal 1    3            1       1 137.62534       1
3 Jackal 1    4            2       1 108.05564       1
4 Jackal 1    5            2       2  33.53684       1
5 Jackal 1    6            2       2  82.94192       1
6 Jackal 1    7            2       1 103.09919       1

Thanks!

Ellen Aikens
GIS Intern
Smithsonian Conservation Biology Institute
1500 Remount Road
Front Royal, VA  22630
[email protected]


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to