R/mask.R

#' Read mask as a RasterLayer
#'
#' @export
#' @param what character specifies resolution "4km" (default) or "9km"
#' @param path character, the path to the masking raster files
#' @return a RasterLayer or NULL
read_mask <- function(what = c("4km", "9km")[1],
    path = obpg_path("gom", "mask")){

    w <- tolower(as.character(what[1]))
    if (!grepl("km", w, fixed = TRUE)) w <- paste0(w, 'km')

    filename = file.path(path,paste0("mask_",w,".grd"))
    if (!file.exists(filename)) stop("file not found", filename)

    raster::raster(filename)
}
btupper/obpgtools documentation built on May 13, 2019, 8:42 a.m.