Dear List,
I would like to draw lines in raster cells with a certain values, I can
work around this with a for loop but as always this solution only works
for small datasets (which is not my case), I would therefore like to
have your opinion on this;
#the code
library(maptools) #to use spRbind
out<-NULL
r1<-raster(ncols=10,nrows=10)
r1[]<-sample(0:1,100,replace=TRUE)
for(i in 1:ncell(r1)){
if(r1[i]==1){
lines<-SpatialLines(list(Lines(list(Line(matrix(c(xyFromCell(r1,i)+(res(r1)/2),xyFromCell(r1,i)-(res(r1)/2)),ncol=2,byrow=TRUE))),ID=as.character(i))))
if(is.null(out)){
out<-lines }
else {out<-spRbind(out,lines)}
}
print(i)
}
Thank you in advance,
--
*HERTZOG* Lionel
2^nd year MSc Organismic Biology
[email protected] <mailto:[email protected]>
(+49)-0 15215149128
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo