R/crop_center.R

Defines functions crop_center

Documented in crop_center

#'@title crop a (raster or stack) from center and quick view with mapview

#'@param ras raster or rasterstack
#'@param vis if True then apply mapview
#'@param size windowsize for cropping, number of pixels from the centre.
#'@export

crop_center= function(ras, size, vis=F,...){
a = crop(c, extent(ras, floor(nrow(ras)/2)-size, floor(nrow(ras)/2)+size, floor(ncol(ras)/2)-size, floor(ncol(ras)/2)+size))
if(vis)
  mapview(a)}
mengluchu/APMtools documentation built on Jan. 27, 2022, 2:41 a.m.