Skip to content

Commit

Permalink
Remove dependency on package maps
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoVilela committed Aug 7, 2023
1 parent ccc7667 commit 85f82d3
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 11 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Imports:
Depends:
R (>= 3.1.0),
terra,
maps,
grDevices,
graphics,
methods,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export(lets.subsetPAM)
export(lets.summarizer)
export(lets.transf)
import(geosphere)
import(maps)
import(sf)
import(terra)
importFrom(grDevices,colorRampPalette)
Expand Down
2 changes: 1 addition & 1 deletion R/letsR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#'
#' @references Vilela, B., & Villalobos, F. (2015). letsR: a new R package for data handling and analysis in macroecology. Methods in Ecology and Evolution.
#'
#' @import geosphere maps terra sf
#' @import geosphere terra sf
#' @importFrom grDevices colorRampPalette dev.new dev.off
#' @importFrom graphics abline par plot.new segments
#' @importFrom methods is
Expand Down
3 changes: 2 additions & 1 deletion R/lets_maplizer.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#' resu <- lets.maplizer(PAM, trait, PAM$S, ras = TRUE)
#' head(resu$Matrix)
#' plot(resu$Raster, xlab = "Longitude", ylab = "Latitude",
#' main = "Mean description year per site") ; map(add = TRUE)
#' main = "Mean description year per site")
#'
#' }
#'
#' @export
Expand Down
3 changes: 3 additions & 0 deletions R/lets_pamcrop.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#'
#' @examples \dontrun{
#' data(PAM)
#' data("wrld_simpl")
#'
#' # PAM before crop
#' plot(PAM, xlab = "Longitude", ylab = "Latitude",
#' main = "Phyllomedusa species richness")
Expand All @@ -30,6 +32,7 @@
#' PAM_crop <- lets.pamcrop(PAM, Brazil, remove.sp = TRUE)
#' plot(PAM_crop, xlab = "Longitude", ylab = "Latitude",
#' main = "Phyllomedusa species richness (Brazil crop)")
#' plot(sf::st_geometry(wrld_simpl), add = TRUE)
#' }
#'
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/lets_presab_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' @examples \dontrun{
#' # Species polygons
#' data("Phyllomedusa")
#'
#' data("wrld_simpl")
#' # Grid
#' sp.r <- terra::as.polygons(terra::rast(resol = 5,
#' crs = terra::crs(Phyllomedusa),
Expand All @@ -45,7 +45,7 @@
#' colors <- c("white", colfunc(max(rich_plus1)))
#' plot(resu$grid, border = "gray40",
#' col = colors[rich_plus1])
#' map(add = TRUE)
#' plot(sf::st_geometry(wrld_simpl), add = TRUE)
#' }
#'
#'
Expand Down
7 changes: 5 additions & 2 deletions R/plot_PresenceAbsence.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ plot.PresenceAbsence <- function(x, name = NULL, world = TRUE,
# Species position in the PAM
pos <- which(x$Sp == name)
# Transform the one species in raster
r <- rasterize(x$Presen[ , 1:2], x$Rich, x$Presen[ , (pos + 2)])
r <- terra::rasterize(x$Presen[ , 1:2],
x$Rich,
x$Presen[ , (pos + 2)])
# Plot
plot(r, col = c("white", col_name), legend = FALSE, ...)
}
if (world) {
map(add = TRUE)
wrld_simpl <- get(utils::data("wrld_simpl", package = "letsR"))
plot(sf::st_geometry(wrld_simpl), add = TRUE)
}
# Avoid return map
invisible(NULL)
Expand Down
3 changes: 3 additions & 0 deletions man/lets.PAMcrop.Rd

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

3 changes: 2 additions & 1 deletion man/lets.maplizer.Rd

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

4 changes: 2 additions & 2 deletions man/lets.presab.grid.Rd

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

Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.
Binary file added tests/testthat/Rplots3.pdf
Binary file not shown.
Binary file removed tests/testthat/testthat-problems.rds
Binary file not shown.

0 comments on commit 85f82d3

Please sign in to comment.