Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Loïc Dutrieux
Hi Thiago, Otherwise overlay wrapped in do.call seems to work. See example below: Cheers, Loïc library(raster) # Create multiple raterStacks s1 <- stack(system.file("external/rlogo.grd", package="raster")) s2 <- s1 * 2 s3 <- s1 * 3 s4 <- s1 * 4 # Create a unnamed list (not sure why it

[R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Thiago V. dos Santos
Hi all, I have a list with five raster stacks, each of them containing 9 layers: > models.list $CanESM2 class : RasterBrick dimensions : 23, 19, 437, 9 (nrow, ncol, ncell, nlayers) resolution : 0.5, 0.5 (x, y) extent : -57.5, -48, -34, -22.5 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat

Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread lyndon . estes
Hi Thiago,  Done in haste, but I think this might do it (it’s on an 8X8 problem though):  stlist <- lapply(1:8, function(x) {  rl <- stack(lapply(1:8, function(y) {    r <- raster(nrow = 10, ncol = 10)    r[] <- sample(1:100, size = ncell(r), replace = TRUE)    r  }))  rl })

Re: [R-sig-Geo] save SpatialPolygonsDataFrame as dxf file

2015-12-02 Thread Milan Cisty
Thank for help. I did only one small correction, because solution from Roger produce so called hatch objects in dxf. I used nlt = "MULTILINESTRING" switch to prevent it. Final code is: library(sp) p = Polygon(coords = matrix(c(1,2,2,1,1,1,1,2,2,1), ncol = 2)) p1= Polygons(list(p), ID=1)

Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Vijay Lulla
Nice use of do.call Loic (Sorry, don't know how to do the accents). I wasn't aware that you can send in a list to args! So, thanks for it. Now here's my quesiton. If I change the statement l <- list(s1,s2,s3,s4,fun=mean) to l <- list(s1=s1,s2=s2,s3=s3,s4=s4,fun=mean) # similar to Thiago's

Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Edzer Pebesma
On 02/12/15 18:28, Loïc Dutrieux wrote: > Hi Vijay, > > I was also wondering about that. The reason I think is that the first > raster* object passed to overlay must be named x= (or unnamed) > > So that > l <- list(x = s1, s2 = s2, s3 = s3, s4 = s4, fun = mean) > > works but, > > l <-

Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Loïc Dutrieux
Hi Vijay, I was also wondering about that. The reason I think is that the first raster* object passed to overlay must be named x= (or unnamed) So that l <- list(x = s1, s2 = s2, s3 = s3, s4 = s4, fun = mean) works but, l <- list(s1 = s1, s2 = s2, s3 = s3, s4 = s4, fun = mean) doesn't.

Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Vijay Lulla
Thanks Edzer. Makes sense! Is there an easier way to inspect what specific function will be resolved to with a particular call other than "getMethod"? For e.g., considering our discussion, how would I have used getMethod (or some other method) to learn how raster::overlay is being called (i.e.

Re: [R-sig-Geo] Take mean of list of raster stacks

2015-12-02 Thread Edzer Pebesma
This is a little off-topic for this list, but I usually do something like: > library(raster) Loading required package: sp > overlay # what is overlay? Ah, it is an S4 method: standardGeneric for "overlay" defined from package "raster" function (x, y, ...) standardGeneric("overlay") Methods may

[R-sig-Geo] How to download MODIS data using MODISTools library

2015-12-02 Thread Waseem Ali
I want to download MODIS product MOD13Q1 to use the Scientific Data Sets (SDS) layers of "250m_16_days_EVI", "250m_16_days_pixel_reliability". MODISTools library in R software provides the capability to download the MODIS data from LP DAAC data center.I have read the MODISTools pdf guide which