[GRASS-stats] Identifing lines with cats in SpatialLinesDataFrame
Jarosław Jasiewicz
jarekj at amu.edu.pl
Fri Mar 7 03:18:25 EST 2008
Hi!
problem concern lines imported to from GRASS, we assume that every
line has its own category
As I rot in the one of the sp man, lines ARE NOT coneted with its
atributes so this means that are not identified by its category, but I
tried on small sample where I calculate generalised direction of line:
dirs=c()
for (i in 1:length(v at lines)) {
tv=coordinates(v)[[i]][[1]]
tl=lm(tv[,1]~tv[,2]) #dir as coef
td=atan(coef(tl)[2])*(180/pi) #coef to degrees
dirs=c(dirs,td) vector with degrees
...
}
lins=data.frame(v$cat,dirs)
I checked direcitons and its look that categories are well subsripted to
its lines
Is that assumption correct? - I of course every line have its own category??
And what about identifing lines with its ID it is its ID from GRASS???
suppose not.
Jarek
P.S here is piece of SpatialLinesDataFrame:
Formal class 'SpatialLinesDataFrame' [package "sp"] with 4 slots
..@ data :'data.frame': 30 obs. of 3 variables:
.. ..$ cat : num [1:30] 10 107 115 140 158 191 206 207 210 227 ...
.. ..$ rzad : num [1:30] 1 1 3 1 3 1 2 1 1 1 ...
.. ..$ link_to: num [1:30] 11 107 11 140 115 191 158 207 210 227 ...
..@ lines :List of 30
.. ..$ :Formal class 'Lines' [package "sp"] with 2 slots
.. .. .. ..@ Lines:List of 1
.. .. .. .. ..$ :Formal class 'Line' [package "sp"] with 1 slots
.. .. .. .. .. .. ..@ coords: num [1:5, 1:2] 3592150 3592130 3592110
3592090 3591850 ...
.. .. .. ..@ ID : chr "0"
.. ..$ :Formal class 'Lines' [package "sp"] with 2 slots
.. .. .. ..@ Lines:List of 1
.. .. .. .. ..$ :Formal class 'Line' [package "sp"] with 1 slots
.. .. .. .. .. .. ..@ coords: num [1:6, 1:2] 3590210 3590210 3590190
3590190 3590170 ...
.. .. .. ..@ ID : chr "1"
.. ..$ :Formal class 'Lines' [package "sp"] with 2 slots
.. .. .. ..@ Lines:List of 1
.. .. .. .. ..$ :Formal class 'Line' [package "sp"] with 1 slots
.. .. .. .. .. .. ..@ coords: num [1:8, 1:2] 3592110 3591930 3591930
3591910 3591910 ...
.. .. .. ..@ ID : chr "2"
.. ..$ :Formal class 'Lines' [package "sp"] with 2 slots
.. .. .. ..@ Lines:List of 1
.. .. .. .. ..$ :Formal class 'Line' [package "sp"] with 1 slots
.. .. .. .. .. .. ..@ coords: num [1:5, 1:2] 3590430 3590350 3590210
3590190
More information about the grass-stats
mailing list