diff --git a/.DS_Store b/.DS_Store index 8d81c9a..dcf19e9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/R/lets_presab_birds.R b/R/lets_presab_birds.R index f020df8..e57ae2b 100644 --- a/R/lets_presab_birds.R +++ b/R/lets_presab_birds.R @@ -6,7 +6,10 @@ #' @description Convert species' ranges (in shapefile format and stored in #' particular folders) into a presence-absence matrix based on a user-defined #' grid. This function is specially designed to work with BirdLife Intl. -#' shapefiles (\url{https://www.birdlife.org}). +#' shapefiles (\url{https://www.birdlife.org}). (Notice that new versions of +#' birds spatial data are in a similar format to other groups and should be +#' run using the lets.presab function. We will keep this function in case +#' someone needs to use on the previous data format.) #' #' @inheritParams lets.presab #' @param path Path location of folders with one or more species' individual diff --git a/man/lets.presab.birds.Rd b/man/lets.presab.birds.Rd index 1f9c816..2b8313f 100644 --- a/man/lets.presab.birds.Rd +++ b/man/lets.presab.birds.Rd @@ -91,7 +91,10 @@ The result is a list object of class \code{\link{PresenceAbsence}} Convert species' ranges (in shapefile format and stored in particular folders) into a presence-absence matrix based on a user-defined grid. This function is specially designed to work with BirdLife Intl. - shapefiles (\url{https://www.birdlife.org}). + shapefiles (\url{https://www.birdlife.org}). (Notice that new versions of + birds spatial data are in a similar format to other groups and should be + run using the lets.presab function. We will keep this function in case + someone needs to use on the previous data format.) } \details{ The function creates the presence-absence matrix based on a raster diff --git a/tests/.DS_Store b/tests/.DS_Store index bf01b1e..91ae8ff 100644 Binary files a/tests/.DS_Store and b/tests/.DS_Store differ diff --git a/tests/testthat/test-lets_distmat.R b/tests/testthat/test-lets_distmat.R index 2f7db1b..520c021 100644 --- a/tests/testthat/test-lets_distmat.R +++ b/tests/testthat/test-lets_distmat.R @@ -25,20 +25,3 @@ test_that("lets.distmat works fine, asdist = FALSE", { }) -test_that("lets.distmat works fine, miles = TRUE", { - - - distPAM <- lets.distmat(PAM, miles = TRUE) - expect_true(class(distPAM)[1] == "dist") - expect_true(all(dim(as.matrix(distPAM)) == dimPAM)) - -}) - -test_that("lets.distmat works fine, xy as matrix ", { - - - distPAM <- lets.distmat(coords, miles = TRUE) - expect_true(class(distPAM)[1] == "dist") - expect_true(all(dim(as.matrix(distPAM)) == nrow(coords))) - -}) diff --git a/tests/testthat/test-lets_gridirizer.R b/tests/testthat/test-lets_gridirizer.R index ebd841b..0903d79 100644 --- a/tests/testthat/test-lets_gridirizer.R +++ b/tests/testthat/test-lets_gridirizer.R @@ -7,7 +7,7 @@ test_that("lets.gridirizer works fine", { resu_test <- lets.gridirizer(PAM) expect_equal(class(resu_test)[1], "list") - expect_true(inherits(resu_test[[1]], "SpatialPolygonsDataFrame")) - expect_equal(class(resu_test[[2]])[1], "matrix") + expect_true(inherits(resu_test[[1]], "SpatVector")) + expect_equal(class(resu_test[[2]])[1], "data.frame") }) diff --git a/tests/testthat/test-lets_maplizer.R b/tests/testthat/test-lets_maplizer.R index c90576b..413a792 100644 --- a/tests/testthat/test-lets_maplizer.R +++ b/tests/testthat/test-lets_maplizer.R @@ -23,7 +23,7 @@ test_that("lets.maplizer works fine", { resu_test <- lets.maplizer(PAM, trait, PAM$S, ras = TRUE) expect_equal(class(resu_test)[1], "list") expect_equal(class(resu_test[[1]])[1], "matrix") - expect_true(inherits(resu_test[[2]], "RasterLayer")) + expect_true(inherits(resu_test[[2]], "SpatRaster")) expect_true(ncol(resu_test[[1]]) == 3) }) diff --git a/tests/testthat/test-lets_presab.R b/tests/testthat/test-lets_presab.R index 232b9a0..5b87103 100644 --- a/tests/testthat/test-lets_presab.R +++ b/tests/testthat/test-lets_presab.R @@ -4,10 +4,24 @@ data(Phyllomedusa) test_that("lets.presab return a correct PresenceAbsence object", { skip_on_cran() - PAM <- lets.presab(Phyllomedusa, xmn=-93, xmx=-29, ymn= -57, ymx=15, - resol=1, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, - origin=NULL, seasonal=NULL, count=FALSE) + PAM <- + lets.presab( + Phyllomedusa, + xmn = -93, + xmx = -29, + ymn = -57, + ymx = 15, + resol = 1, + remove.cells = TRUE, + remove.sp = TRUE, + show.matrix = FALSE, + crs = terra::crs("+proj=longlat +datum=WGS84"), + cover = 0, + presence = NULL, + origin = NULL, + seasonal = NULL, + count = FALSE + ) expect_equal(class(PAM), "PresenceAbsence") expect_true(is.matrix(PAM[[1]])) expect_true(inherits(PAM[[2]], "SpatRaster")) @@ -21,7 +35,7 @@ test_that("lets.presab return a correct PresenceAbsence object for the world", { PAM <- lets.presab(Phyllomedusa, resol=5, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) @@ -40,7 +54,7 @@ test_that("lets.presab return a correct PresenceAbsence object (count=TRUE)", { PAM <- lets.presab(Phyllomedusa, xmn=-93, xmx=-29, ymn= -57, ymx=15, resol=1, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, origin=NULL, seasonal=NULL, count=TRUE) expect_equal(class(PAM), "PresenceAbsence") @@ -57,7 +71,7 @@ test_that("lets.presab return a correct PresenceAbsence object, cover=0.2", { PAM <- lets.presab(Phyllomedusa, xmn=-93, xmx=-29, ymn= -57, ymx=15, resol=1, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") @@ -74,7 +88,7 @@ test_that("lets.presab return a correct PresenceAbsence object different project pro <- paste("+proj=eqdc +lat_0=-32 +lon_0=-60 +lat_1=-5", "+lat_2=-42 +x_0=0 +y_0=0 +ellps=aust_SA", "+units=m +no_defs") - SA_EC <- CRS(pro) + SA_EC <- terra::crs(pro) PAM_proj <- lets.presab(shapes = Phyllomedusa, xmn = -4135157, xmx = 4707602, @@ -97,7 +111,7 @@ test_that("lets.presab return a correct PresenceAbsence object, remove.sp=FALSE" PAM <- lets.presab(Phyllomedusa, xmn=-93, xmx=-29, ymn= -57, ymx=15, resol=1, remove.cells=TRUE, remove.sp=FALSE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") @@ -117,7 +131,7 @@ test_that("lets.presab return a correct PresenceAbsence object, remove.cells=FAL PAM <- lets.presab(Phyllomedusa, xmn=-93, xmx=-29, ymn= -57, ymx=15, resol=1, remove.cells=FALSE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") diff --git a/tests/testthat/test-lets_presab_birds.R b/tests/testthat/test-lets_presab_birds.R index 6affdba..f502531 100644 --- a/tests/testthat/test-lets_presab_birds.R +++ b/tests/testthat/test-lets_presab_birds.R @@ -7,7 +7,7 @@ test_that("lets.presab.birds return a correct PresenceAbsence object", { skip_on_cran() PAM <- lets.presab.birds(path.Ramphastos, xmn=-93, xmx=-29, ymn= -57, ymx=25, resol=1, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM)[1], "PresenceAbsence") @@ -21,7 +21,7 @@ test_that("lets.presab.birds return a correct PresenceAbsence object for the wor skip_on_cran() PAM <- lets.presab.birds(path.Ramphastos, resol=5, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") @@ -38,7 +38,7 @@ test_that("lets.presab.birds return a correct PresenceAbsence object for cover d pro <- paste("+proj=eqdc +lat_0=-32 +lon_0=-60 +lat_1=-5", "+lat_2=-42 +x_0=0 +y_0=0 +ellps=aust_SA", "+units=m +no_defs") - SA_EC <- suppressWarnings(CRS(pro)) + SA_EC <- suppressWarnings(terra::crs(pro)) PAM3 <- lets.presab.birds(path.Ramphastos, xmn = -4135157, xmx = 4707602, @@ -60,7 +60,7 @@ test_that("lets.presab.birds return a correct PresenceAbsence object (count=TRUE PAM <- lets.presab.birds(path.Ramphastos, xmn=-93, xmx=-29, ymn= -57, ymx=25, resol=1, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, origin=NULL, seasonal=NULL, count=TRUE) expect_equal(class(PAM), "PresenceAbsence") expect_true(is.matrix(PAM[[1]])) @@ -74,7 +74,7 @@ test_that("lets.presab.birds return a correct PresenceAbsence object, cover=0.2" PAM <- lets.presab.birds(path.Ramphastos, xmn=-93, xmx=-29, ymn= -57, ymx=25, resol=1, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0.2, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") @@ -92,7 +92,7 @@ test_that("lets.presab.birds return a correct PresenceAbsence object, PAM <- lets.presab.birds(path.Ramphastos, xmn=-93, xmx=-29, ymn= -57, ymx=25, resol=1, remove.cells=TRUE, remove.sp=FALSE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover = 0.999999, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover = 0.999999, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") expect_true(is.matrix(PAM[[1]])) @@ -106,7 +106,7 @@ test_that("lets.presab.birdsreturn a correct PresenceAbsence object, remove.cell PAM <- lets.presab.birds(path.Ramphastos, xmn=-93, xmx=-29, ymn= -57, ymx=25, resol=1, remove.cells=FALSE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, origin=NULL, seasonal=NULL, count=FALSE) expect_equal(class(PAM), "PresenceAbsence") @@ -124,12 +124,12 @@ test_that("lets.presab.birdsreturn a correct PresenceAbsence object, remove.cell test_that("lets.presab.birds new projection", { skip_on_cran() - desiredcrs <- CRS("+proj=laea +lat_0=0 +lon_0=-80 +x_0=180 +y_0=70 +units=km") + desiredcrs <- terra::crs("+proj=laea +lat_0=0 +lon_0=-80 +x_0=180 +y_0=70 +units=km") PAM <- lets.presab.birds(path.Ramphastos, xmn = -3000, xmx = 6000, ymn = -5000, ymx = 3000, res = 100, remove.cells=TRUE, remove.sp=TRUE, show.matrix=FALSE, - crs=CRS("+proj=longlat +datum=WGS84"), cover=0, + crs=terra::crs("+proj=longlat +datum=WGS84"), cover=0, presence=NULL, crs.grid = desiredcrs, origin=NULL, seasonal=NULL, count=TRUE)