setExtent(x, ext, keepres=FALSE, snap=FALSE)
extent(x) <- value
extent
, or an object that has an extent (e.g. a Raster* or Spatial* object) )TRUE
, the resolution of the cells will stay the same after adjusting the bounding box (by adjusting the number of rows and columns).
If FALSE
, the number of rows and columns will stay the same, and the resolution TRUE
, the extent is adjusted so that the cells of the input and output RasterLayer are alignedextent
)extent
, Extent-class
r <- raster()
bb <- extent(-10, 10, -20, 20)
extent(r) <- bb
r <- setExtent(r, bb, keepres=TRUE)
Run the code above in your browser using DataLab