Skip to content

Commit

Permalink
Fixing wwarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio-berti committed Feb 9, 2021
1 parent d6136d6 commit 9cff7ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion R/en_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#' @param plot if TRUE plot the path
#' @return A list with elements the path, its travel distance and energy costs.
#' @examples
#' \dontrun{
#' \donttest{
#' library(raster)
#' library(enerscape)
#' data("volcano")
#' dem <- raster(volcano)
#' en <- enerscape(dem, 10, unit = "kcal", neigh = 16)
Expand Down
19 changes: 8 additions & 11 deletions R/enerscape.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,19 @@ enerscape <- function(
# as global variable and deleted before return. Deletion takes place in the
# parent environment of the function.
en_res <- raster::res(dem)[1]
# assign("enerscape", new.env())
# assign("en_res", raster::res(dem)[1], envir = enerscape)
message(" - Raster cells are assumed to have same horizontal and vertical",
" resolution and with planar coordinate reference system (e.g. UTM)")
oldw <- getOption("warn")
options("warn" = -1)
message(" | Calculating slope")
height <- gdistance::transition(dem,
function(x) {
x[2] - x[1]
},
directions = neigh,
symm = FALSE)
height <- suppressWarnings( #this warning is printed as message before return
gdistance::transition(dem,
function(x) {
x[2] - x[1]
},
directions = neigh,
symm = FALSE)
)
slope <- gdistance::geoCorrection(height, scl = FALSE)
slope <- atan(slope) * 180 / pi #convert slope ratio to degrees
options("warn" = oldw)
adj <- raster::adjacent(dem,
1:raster::ncell(dem),
pairs = TRUE,
Expand Down

0 comments on commit 9cff7ad

Please sign in to comment.