diff --git a/DESCRIPTION b/DESCRIPTION index 7093a66c..96c25c60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -49,7 +49,7 @@ Remotes: inbo/inborutils Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 Suggests: googledrive, knitr, @@ -58,6 +58,7 @@ Suggests: readxl, remotes, rmarkdown, + sp, tidyverse, units VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index e5ee8de1..4116d49b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,7 +78,6 @@ importFrom(rprojroot,is_rstudio_project) importFrom(sf,"st_crs<-") importFrom(sf,read_sf) importFrom(sf,st_centroid) -importFrom(sf,st_crs) importFrom(sf,st_drop_geometry) importFrom(sf,st_transform) importFrom(stats,setNames) diff --git a/R/GRTSmh.R b/R/GRTSmh.R index d5ad3921..0cc8368d 100644 --- a/R/GRTSmh.R +++ b/R/GRTSmh.R @@ -309,8 +309,6 @@ convert_base4frac_to_dec <- #' } #' #' @export -#' @importFrom sf -#' st_crs #' @importFrom raster #' raster #' brick @@ -323,6 +321,12 @@ read_GRTSmh <- "20_processed/GRTSmh_brick/GRTSmh_brick.tif"), brick = FALSE) { + if (!requireNamespace("sp", quietly = TRUE)) { + stop("Package \"sp\" is needed when using this function. ", + "Please install it.", + call. = FALSE) + } + if (brick) { if (missing(file)) { b <- brick(file.path(path, file[2]))} else { @@ -337,7 +341,7 @@ read_GRTSmh <- } result <- r } - crs(result) <- st_crs(31370)$proj4string + crs(result) <- sp::CRS(SRS_string = "EPSG:31370") return(result) } @@ -427,16 +431,21 @@ read_GRTSmh <- #' } #' #' @export -#' @importFrom sf -#' st_crs #' @importFrom raster #' raster #' crs<- read_GRTSmh_base4frac <- function(path = fileman_up("n2khab_data"), file = "20_processed/GRTSmh_base4frac/GRTSmh_base4frac.tif") { + + if (!requireNamespace("sp", quietly = TRUE)) { + stop("Package \"sp\" is needed when using this function. ", + "Please install it.", + call. = FALSE) + } + r <- raster(file.path(path, file)) - crs(r) <- st_crs(31370)$proj4string + crs(r) <- sp::CRS(SRS_string = "EPSG:31370") return(r) } @@ -579,7 +588,6 @@ read_GRTSmh_base4frac <- #' @importFrom stringr str_c #' @importFrom sf #' read_sf -#' st_crs #' st_crs<- #' @importFrom raster #' raster @@ -608,11 +616,17 @@ read_GRTSmh_diffres <- } else { + if (!requireNamespace("sp", quietly = TRUE)) { + stop("Package \"sp\" is needed when using this function. ", + "Please install it.", + call. = FALSE) + } + r <- raster(file.path(path, subdir, str_c("GRTSmh_diffres.", level, ".tif"))) names(r) <- str_c("level", level) - crs(r) <- st_crs(31370)$proj4string + crs(r) <- sp::CRS(SRS_string = "EPSG:31370") r }