Skip to content

Commit

Permalink
Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio-berti committed May 21, 2021
1 parent d3e072d commit 0641814
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Description: Compute energy landscapes using a digital elevation model (DEM)
Expand All @@ -13,6 +13,7 @@ Imports:
raster,
gdistance,
rgdal,
rgeos,
sp,
Matrix
Suggests:
Expand Down
4 changes: 2 additions & 2 deletions R/circuitscape.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions R/en_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion R/enerscape.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/least-cost_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions R/omniscape.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion man/en_path.Rd

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

2 changes: 1 addition & 1 deletion man/enerscape.Rd

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

0 comments on commit 0641814

Please sign in to comment.