R/utils.R

Defines functions check_output check_input check_is_raster

check_is_raster = function(x){
  if (!(methods::is(x, "SpatRaster"))){
    if (methods::is(x, "RasterLayer") || methods::is(x, "RasterStack") || methods::is(x, "RasterBrick")){
      return(TRUE)
    } else {
      stop("x needs to be either SpatRaster, RasterStack or RasterBrick", call. = FALSE)
    }
  } else{
    return(FALSE)
  }
}
check_input = function(x, is_raster){
  if (is_raster){
      x = terra::rast(x)
  }
  return(x)
}
check_output = function(out, is_raster){
  if (is_raster){
    out = raster::stack(out)
  }
  return(out)
}

Try the raceland package in your browser

Any scripts or data that you put into this service are public.

raceland documentation built on April 14, 2023, 5:09 p.m.