don't forget to do this at multiple raster resolutions in order to compute the box-count dimension! 


Lee De Cola, PhD, MCP. 
DATA to Insight 
LDECOLA@COMCAST.NET 
Reston, Virginia 
703 709 6972 
571 315 0577 mobile 
----- Original Message -----
From: "Alexandre Villers" <villers.alexandre@gmail.com> 
To: "Aide R SIG GEO" <r-sig-geo@stat.math.ethz.ch> 
Sent: Thursday, November 28, 2013 11:28:20 AM 
Subject: [R-sig-Geo] rasterize SpatialLines 

Dear list, 

I'm trying to rasterize a SpatialLines object, which represents the path 
of an individual (created from the points locations). 
I would like to know the number of times he visited a given pixel. 
Following the example (slightly modified) in raster::rasterize 


cds1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60)) 
cds2 <- rbind(c(-10,0), c(140,60), c(160,0), c(140,-55), c(50,100)) 
cds3 <- rbind(c(-125,0), c(0,60), c(40,5), c(15,-45)) 

lines <- SpatialLines(list(Lines(list(Line(cds1)), "1"), 
Lines(list(Line(cds2)), "2"), Lines(list(Line(cds3)), "3") )) 

r <- raster(ncols=90, nrows=45) 
rl <- rasterize(lines, r, fun='count') 
plot(rl) 
lines (lines) 

It's clear from the figure that a pixel that is "visited" twice by a 
SpatialLines with the same ID isn't counted twice (which I would like) 
compared to a pixel visited twice by SpatialLines of 2 different IDs. 

I guess I could build a SpatialLines object with each segment bearing a 
different ID but I suspect there is a more elegant way. However I 
couldn't figure out what function to specify (though I'm pretty sure 
once I'll see the answer, it will become obvious...). 

Any hint ? 

Thanks in advance 

Alex 

_______________________________________________ 
R-sig-Geo mailing list 
R-sig-Geo@r-project.org 
https://stat.ethz.ch/mailman/listinfo/r-sig-geo 

	[[alternative HTML version deleted]]

