Skip to content

Commit

Permalink
handle errors with SOLUS index
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Oct 22, 2024
1 parent 48d865e commit ef86fd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions R/fetchSOLUS.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
#' # plot, truncating each profile to the predicted restriction depth
#' aqp::plotSPC(trunc(res, 0, res$resdept_p), color = "claytotal_p", divide.hz = FALSE)
fetchSOLUS <- function(x = NULL,
depth_slices = c("0", "5", "15", "30", "60", "100", "150"),
depth_slices = c(0, 5, 15, 30, 60, 100, 150),
variables = c("anylithicdpt", "caco3", "cec7", "claytotal",
"dbovendry", "ec", "ecec", "fragvol", "gypsum",
"ph1to1h2o", "resdept", "sandco", "sandfine",
Expand All @@ -127,11 +127,15 @@ fetchSOLUS <- function(x = NULL,
method <- match.arg(method[1], c("linear", "constant", "fmm", "periodic", "natural", "monoH.FC", "hyman", "step", "slice"))

# get index of SOLUS COGs
ind <- .get_SOLUS_index()
ind <- try(.get_SOLUS_index())

if (inherits(ind, 'try-error')) {
stop("Failed to fetch SOLUS grid index", call. = FALSE)
}

# subset based on user specified properties, depths, and product type
isub <- ind[ind$property %in% variables &
ind$depth_slice %in% c("all", depth_slices) &
as.character(ind$depth_slice) %in% c("all", depth_slices) &
ind$filetype %in% output_type,]

isub$subproperty <- gsub("\\.tif$", "", isub$filename)
Expand Down
2 changes: 1 addition & 1 deletion man/fetchSOLUS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef86fd7

Please sign in to comment.