From 06418146bf3d1b11964cf214207bcaf00e4c6557 Mon Sep 17 00:00:00 2001 From: emilio-berti Date: Fri, 21 May 2021 09:08:05 +0200 Subject: [PATCH] Checks --- DESCRIPTION | 3 ++- R/circuitscape.R | 4 ++-- R/en_path.R | 6 ++++-- R/enerscape.R | 2 +- R/least-cost_path.R | 2 +- R/omniscape.R | 4 ++-- man/en_path.Rd | 3 ++- man/enerscape.Rd | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 607adb9..469c1c0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: enerscape Type: Package Title: Compute Energy Landscapes -Version: 0.1.0 +Version: 0.1.1 Author: Emilio Berti Maintainer: Emilio Berti Description: Compute energy landscapes using a digital elevation model (DEM) @@ -13,6 +13,7 @@ Imports: raster, gdistance, rgdal, + rgeos, sp, Matrix Suggests: diff --git a/R/circuitscape.R b/R/circuitscape.R index aa95540..ada2540 100644 --- a/R/circuitscape.R +++ b/R/circuitscape.R @@ -22,8 +22,8 @@ circuitscape_skeleton <- function( stop("points are not data.frame or matrix") } } - pr <- raster::rasterize(points, en$rasters$Work, na.rm = TRUE) - raster::writeRaster(en$rasters$Work, file.path(path, "/work.tif"), + pr <- raster::rasterize(points, en$rasters$EnergyScape, na.rm = TRUE) + raster::writeRaster(en$rasters$EnergyScape, file.path(path, "/work.tif"), overwrite = TRUE) raster::writeRaster(pr, file.path(path, "/loc.tif"), overwrite = TRUE) diff --git a/R/en_path.R b/R/en_path.R index cbf50f4..e407730 100644 --- a/R/en_path.R +++ b/R/en_path.R @@ -16,7 +16,9 @@ #' data("volcano") #' dem <- raster(volcano) #' en <- enerscape(dem, 10, unit = "kcal", neigh = 16) -#' en_path(en, draw = TRUE, n = 10) +# p <- coordinates(en$rasters$DEM)[sample(1:ncell(en$rasters$DEM), 5), ] +# path <- sp::SpatialLines(list(sp::Lines(sp::Line(p), ID = "path"))) +# en_path(en, path) #' } #' @export #' @references Etten, J. van. (2017). R Package gdistance: Distances and Routes @@ -51,7 +53,7 @@ en_path <- function( } else if (class(p)[1] != "SpatialLines") { stop("Path must be a SpatialLines object") } - w <- raster::extract(en$rasters$Work, p)[[1]] + w <- raster::extract(en$rasters$EnergyScape, p)[[1]] ans <- list(Path = p, Distance = sp::SpatialLinesLengths(p), Cost = sum(w)) diff --git a/R/enerscape.R b/R/enerscape.R index e03f543..bc27ab5 100644 --- a/R/enerscape.R +++ b/R/enerscape.R @@ -14,7 +14,7 @@ #' Prampero et al. (1979). #' @param v speed of cyclist (km / h), only for \code{method = 'cycling'}. #' @return A list with elements a rasterStack of the digital elevation model, -#' slope, work, and conductance and the conductance as a transitionLayer for +#' slope, energy landscape, and conductance and the conductance as a transitionLayer for #' path analysis. #' @details From the digital elevation model, transition slopes, energy costs #' and conductances (1 / work) are computed based on the model described in diff --git a/R/least-cost_path.R b/R/least-cost_path.R index 4da4433..38fd5cf 100644 --- a/R/least-cost_path.R +++ b/R/least-cost_path.R @@ -33,7 +33,7 @@ en_lcp <- function( stop("en must be an enerscape object") } else { x <- en$rasters$DEM - work <- en$rasters$Work + work <- en$rasters$EnergyScape cond <- en$cond_tr } ans <- list() #initialize return value diff --git a/R/omniscape.R b/R/omniscape.R index 800b68d..a5b99e3 100644 --- a/R/omniscape.R +++ b/R/omniscape.R @@ -18,9 +18,9 @@ omniscape_skeleton <- function( stop("Missing mandatory input") } if (aggr_fact > 1) { - w <- raster::aggregate(en$rasters$Work, aggr_fact) + w <- raster::aggregate(en$rasters$EnergyScape, aggr_fact) } else { - w <- en$rasters$Work + w <- en$rasters$EnergyScape } raster::writeRaster(w, file.path(path, "/work.tif"), overwrite = TRUE) diff --git a/man/en_path.Rd b/man/en_path.Rd index b9989e0..2eb39ce 100644 --- a/man/en_path.Rd +++ b/man/en_path.Rd @@ -26,8 +26,9 @@ Optionally, the path can be selected by specifying the number of nodes and clicking on the plot. } \examples{ -\dontrun{ +\donttest{ library(raster) +library(enerscape) data("volcano") dem <- raster(volcano) en <- enerscape(dem, 10, unit = "kcal", neigh = 16) diff --git a/man/enerscape.Rd b/man/enerscape.Rd index e96a9c8..a6b66b7 100644 --- a/man/enerscape.Rd +++ b/man/enerscape.Rd @@ -24,7 +24,7 @@ Prampero et al. (1979).} } \value{ A list with elements a rasterStack of the digital elevation model, - slope, work, and conductance and the conductance as a transitionLayer for + slope, energy landscape, and conductance and the conductance as a transitionLayer for path analysis. } \description{