I am trying to create a raster stack from a rasterlayer, where the raster stack is just the same raster layer repeated a certain number of times.
I can do something like this:
library(raster)
rasterstack <- addLayer(rasterlayer, rasterLayer, rasterLayer)
and this works. However, i want the stack to be about a 1000 layers. I guess i could just loop through, but i was wondering if there was a more sophisticated way to doing this.
The reason I am trying to do this is to calculate the weighted mean of a raster stack with data where each layer is a different time period, and where the weights are in a different raster layer object. I am hoping that if I create a rasterstack from the weights raster layer with the same number of layers as the data, I'll be able to do something like:
weightedmean <- weighted.mean( data.RasterStack, weights.RasterStack )