R/checkInputs.R

Defines functions .checkInputs

#' Check inputs to caribouHabitat
#'
#' Check the inputs that are needed in processData or updateCaribou so the
#' errors happen before data is processed.
#'
#' @noRd

.checkInputs <- function(caribouRange, winArea, landCover, coefTable) {
  expectedRanges <- unique(coefTable$Range)
  
  if(any(!caribouRange$Range %in% expectedRanges)){
    stop("Caribou Range must match one of: ", expectedRanges, call. = FALSE)
  }
  
  if(!is.null(winArea)){
    if(!is.numeric(winArea)){
      stop("winArea must be a number (in hectares)", call. = FALSE)
    }
  }
  
  if(!all(terra::unique(landCover)[,1] %in% resTypeCode$code)){
    stop("landCover raster has values outside the range of: ", 
         paste0(resTypeCode$code, collapse = ", "), 
         ". landCover must be reclassified to resource types",
         call. = FALSE)
  }

}
  
LandSciTech/caribouMetrics documentation built on Feb. 3, 2024, 9:41 p.m.