[R-sig-Geo] regularly subset (subsample) a raster and get a raster

Jean-Luc Dupouey dupouey at nancy.inra.fr
Wed Sep 3 13:56:01 CEST 2014


Dear forumites,

Using R, I want to regularly subsample a raster (for example, one point 
over two), and get a raster.

Usual R subsampling works with raster layers:

MyRaster[seq(1,nrow(MyRaster),2),seq(1,ncol(MyRaster),2))]

but it only gives in return a vector of values, not a raster layer 
object. All the raster information is lost (spatial reference, etc.).

How can I subsample my initial raster and still keep a raster?

I thought of using "aggregate" or "crop" functions, but I am working on 
large datasets, and I would prefer to avoid any unnecessary calculations.

Thank you in advance,

Jean-Luc



More information about the R-sig-Geo mailing list