Skip to content

Commit

Permalink
use rlang::check_installed() in tar_*() funs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aariq committed Mar 15, 2024
1 parent cc69c1d commit 239bcbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
6 changes: 1 addition & 5 deletions R/tar-terra-rast.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ tar_terra_rast <- function(name,
retrieval = targets::tar_option_get("retrieval"),
cue = targets::tar_option_get("cue")) {

rlang::check_installed("terra")
name <- targets::tar_deparse_language(substitute(name))

envir <- targets::tar_option_get("envir")
Expand Down Expand Up @@ -95,11 +96,6 @@ tar_terra_rast <- function(name,
#' @param ... Additional arguments not yet used
#' @noRd
create_format_terra_raster <- function(filetype, gdal, ...) {

if (!requireNamespace("terra")) {
stop("package 'terra' is required", call. = FALSE)
}

# get list of drivers available for writing depending on what the user's GDAL supports
drv <- terra::gdal(drivers = TRUE)
drv <- drv[drv$type == "raster" & grepl("write", drv$can), ]
Expand Down
11 changes: 1 addition & 10 deletions R/tar-terra-vect.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ tar_terra_vect <- function(name,
storage = targets::tar_option_get("storage"),
retrieval = targets::tar_option_get("retrieval"),
cue = targets::tar_option_get("cue")) {
rlang::check_installed("terra")
name <- targets::tar_deparse_language(substitute(name))

envir <- targets::tar_option_get("envir")
Expand Down Expand Up @@ -112,11 +113,6 @@ tar_terra_vect <- function(name,
#' @param ... Additional arguments not yet used
#' @noRd
create_format_terra_vect <- function(filetype, options, ...) {

if (!requireNamespace("terra")) {
stop("package 'terra' is required", call. = FALSE)
}

# get list of drivers available for writing depending on what the user's GDAL supports
drv <- terra::gdal(drivers = TRUE)
drv <- drv[drv$type == "vector" & grepl("write", drv$can), ]
Expand Down Expand Up @@ -153,11 +149,6 @@ create_format_terra_vect <- function(filetype, options, ...) {
#' @param ... Additional arguments not yet used
#' @noRd
create_format_terra_vect_shz <- function(options, ...) {

if (!requireNamespace("terra")) {
stop("package 'terra' is required", call. = FALSE)
}

.write_terra_vector <- function(object, path) {
terra::writeVector(
x = object,
Expand Down

0 comments on commit 239bcbd

Please sign in to comment.