Skip to content

Commit

Permalink
Merge pull request #9 from danflop/master_fix
Browse files Browse the repository at this point in the history
Merge and fix conflicts between master and cran_v1 branches
  • Loading branch information
bjohnso005 authored Oct 18, 2023
2 parents 17eb64f + b6a2931 commit 9877d6f
Show file tree
Hide file tree
Showing 130 changed files with 99 additions and 214 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
^.*\.Rproj$
^\.Rproj\.user$
^doc$
^docs$
^Meta$
^_pkgdown\.yml$
^CRAN-SUBMISSION$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ DESCRIPTION
vignettes/fastDiversity_cache/*
doc
Meta
CRAN-SUBMISSION
29 changes: 14 additions & 15 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ Package: changeRangeR
Type: Package
Title: Change Metrics for Species Geographic Ranges
Version: 1.1.0
Author: c(person('Peter J.', 'Galante',email='pgalante@amnh.org',role=c('aut','cre')),
person('Samuel','Chang',email='changalfsam@gmail.com',role=c('aut'))
person('Andrea','Paz',email='paz.andreita@gmail.com',role=c('aut'))
person('Jamie M.','Kass',email='jamie.kass@oist.jp',role=c('aut'))
person('Matthew','Aiello-Lammens',email='maiellolammens@pace.edu',role=c('aut'))
person('Beth','Gerstner',email='gerstn11@msu.edu',role=c('aut'))
person('Bethany A.','Johnson',email='bjohnso005@citymail.cuny.edu',role=c('aut'))
person('Cory','Merow',email='cory.merow@gmail.com',role=c('aut'))
person('Elkin','Noguera-Urbano',email='enoguera@humboldt.org.co',role=c('aut'))
person('Gonzalo E.','Pinilla-Buitrago',email='gpinillabuitrago@gradcenter.cuny.edu',role=c('aut'))
person('Dan','Rosauer',email='dan.rosauer@anu.edu.au',role=c('aut'))
person('Mary E.','Blair',email='mblair1@amnh.org',role=c('aut')))
Maintainer: The package maintainer <mblair1@amnh.org>
Description: Facilitates workflows to reproducibly transform estimates of species’ distributions into metrics relevant for conservation. For example, combining predictions from species distribution models with other maps of environmental data to characterize the proportion of a species’ range that is under protection, calculating metrics used under the IUCN Criteria A and B guidelines (Area of Occupancy and Extent of Occurrence), and calculating more general metrics such as taxonomic and phylogenetic diversity, as well as endemism. Also facilitates temporal comparisons among biodiversity metrics to inform efforts towards complementarity and consideration of future scenarios in conservation decisions. changeRangeR also provides tools to determine the effects of modeling decisions through sensitivity tests.
Authors@R: c(person('Peter J.', 'Galante',email='pgalante@amnh.org',role=c('aut')),
person('Samuel','Chang',email='changalfsam@gmail.com',role=c('aut')),
person('Andrea','Paz',email='paz.andreita@gmail.com',role=c('aut')),
person('Jamie M.','Kass',email='jamie.kass@oist.jp',role=c('aut')),
person('Matthew','Aiello-Lammens',email='maiellolammens@pace.edu',role=c('aut')),
person('Beth','Gerstner',email='gerstn11@msu.edu',role=c('aut')),
person('Bethany A.','Johnson',email='bjohnso005@citymail.cuny.edu',role=c('aut')),
person('Cory','Merow',email='cory.merow@gmail.com',role=c('aut')),
person('Elkin','Noguera-Urbano',email='enoguera@humboldt.org.co',role=c('aut')),
person('Gonzalo E.','Pinilla-Buitrago',email='gpinillabuitrago@gradcenter.cuny.edu',role=c('aut')),
person('Dan','Rosauer',email='dan.rosauer@anu.edu.au',role=c('aut')),
person('Mary E.','Blair',email='mblair1@amnh.org',role=c('aut','cre')))
Description: Facilitates workflows to reproducibly transform estimates of species’ distributions into metrics relevant for conservation. For example, combining predictions from species distribution models with other maps of environmental data to characterize the proportion of a species’ range that is under protection, calculating metrics used under the IUCN Criteria A and B guidelines (Area of Occupancy and Extent of Occurrence), and calculating more general metrics such as taxonomic and phylogenetic diversity, as well as endemism. Also facilitates temporal comparisons among biodiversity metrics to inform efforts towards complementarity and consideration of future scenarios in conservation decisions. 'changeRangeR' also provides tools to determine the effects of modeling decisions through sensitivity tests.
License: GPL-3
VignetteBuilder: knitr
Encoding: UTF-8
Expand All @@ -41,4 +40,4 @@ Suggests:
R.utils,
tools,
dismo
RoxygenNote: 7.2.0
RoxygenNote: 7.2.3
15 changes: 11 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
changeRangeR 1.1.0
=============
- removed expiring packages (maptools, rgeos, rgdal)
- updated vignettes, website, & links
- moved repo to `wallaceEcoMod`
- Removed expiring packages (maptools, rgeos, rgdal)
- Updated vignettes, website, & links
- Moved repo to `wallaceEcoMod`

changeRangeR 1.0.2
=============
- Fixed broken links that needed updating in the website and vignette.

changeRangeR 1.0.1
=============

changeRangeR 1.0.0
=============
- on CRAN
- On CRAN
- Publication: https://doi.org/10.1111/csp2.12863
2 changes: 1 addition & 1 deletion R/SE.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @title Calculate species endemism
#' @description Calculate species endemism as the number of species in a place divided by the total number of places in which those species are found.
#' @param rStack a rasterStack of binary species presences
#' @return raster object showing species endemism.
#' @return Raster object showing species endemism.
#' @author pgalante@@amnh.org
#' @examples
#' # create binary raster
Expand Down
4 changes: 2 additions & 2 deletions R/aooArea.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#' (only if locs argument is supplied).
#' @examples
#' # create raster
#' r1 <- raster::raster(nrows=108, ncols=108, xmn=-50, xmx=50)
#' raster::values(r1)<- runif(n = (108*108))
#' r1 <- raster::raster(nrows=5, ncols=5, xmn=-5, xmx=5, ymn=-5, ymx=5)
#' raster::values(r1)<- runif(n = (5*5))
#' r1[r1 < 0.5] <- NA
#' r1[!is.na(r1)] <- 1
#' # calculate aooArea
Expand Down
8 changes: 4 additions & 4 deletions R/cRRrmm.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @title Create metadata objects from changeRangeR
#' @description Creates and populates a \code{rangeModelMetadata} object from the output of \code{changeRangeR}.
#' See Merow \emph{et al.} (2019) for more details on the nature of the metadata and the \code{rangeModelMetadata} package.
#' @title Create metadata objects from 'changeRangeR'
#' @description Creates and populates a 'rangeModelMetadata' object from the output of 'changeRangeR'.
#' See Merow et al. (2019) <doi:10.1111/geb.12993> for more details on the nature of the metadata and the 'rangeModelMetadata' package.
#' To improve reproducibility of the study, this metadata object can be used as supplemental information for a manuscript, shared with collaborators, etc.
#' @param rmm rangeModelMetadata object: if included, fields are appended to this RMM object as opposed to returning a new RMM object
#' @param rmm 'rangeModelMetadata' object: if included, fields are appended to this RMM object as opposed to returning a new RMM object
#' @param binaryRange Raster layer of a binary SDM. Must be either unprojected in the WGS84 datum, or projected in a UTM projection measured in meters.
#' @param rmm A `rangemodelmetadata` object.
#' @param locs `data.frame` of occurrence records: Longitude and latitude.
Expand Down
12 changes: 6 additions & 6 deletions R/envChange.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
#' @export


#SDM <- raster::raster("inst/extdata/DemoData/SDM/olinguito/olinguitoSDM.tif")
#binaryRange <- raster::raster("inst/extdata/DemoData/SDM/olinguito/Climatically_suitable_projected1.tif")
#SDM <- raster::raster("inst/extdata/DemoData/SDM/olinguitoSDM_coarse.tif")
#binaryRange <- raster::raster("inst/extdata/DemoData/SDM/Climatically_suitable_projected_coarse.tif")
#binaryRange <- raster::projectRaster(binaryRange, SDM, method = "bilinear")
#rStack <- raster::stack(list.files(path = "inst/extdata/DemoData/MODIS", pattern = "\\.tif$", full.names = T))
#rStack <- raster::stack(list.files(path = "inst/extdata/DemoData/MODIS", pattern = "\\.tif$", full.names = TRUE))
#rStack <- raster::projectRaster(rStack, SDM, method = 'bilinear')
#threshold <- 50.086735
#test <- envChange(rStack, binaryRange, threshold, bound = "upper")
#test2 <- envChange(rStack, binaryRange, threshold, bound = "lower")

envChange <- function(rStack, binaryRange, threshold, bound, correlation = F){
envChange <- function(rStack, binaryRange, threshold, bound, correlation = FALSE){
#require(raster)

# if binaryRange is a shapefile, convert to raster then run like normal
Expand All @@ -51,7 +51,7 @@ envChange <- function(rStack, binaryRange, threshold, bound, correlation = F){
}

if(bound == "lower"){
# if(correlation = FALSE){
# if(correlation == FALSE){
rStack[rStack < threshold] <- NA
rStack[rStack > threshold] <- 1
# } else {
Expand Down Expand Up @@ -89,7 +89,7 @@ envChange <- function(rStack, binaryRange, threshold, bound, correlation = F){
if (!raster::isLonLat(maskStack)){
areas <- lapply(masks, function(x) raster::res(x)[[1]] * raster::ncell(x[!is.na(x)]))
} else {
area <- lapply(masks, raster::area, na.rm = T)
area <- lapply(masks, raster::area, na.rm = TRUE)
areas.1 <- lapply(area, function(x) x[!is.na(x)])
areas <- lapply(areas.1, function(x) length(x) * stats::median(x))
#areas <- lapply(masks, raster::area)
Expand Down
7 changes: 3 additions & 4 deletions R/mcpSDM.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' this is then used to delineate the hull
#' @description Implements the technique to estimate IUCN's extent of occurrence (EOO) geographic range estimate of species
#' threat level by delineating a minimum convex polygon (i.e., convex hull) around a thresholded SDM prediction, first
#' described by Syfert et al. (2014). For each increment of 0.01 between a user-specified threshold and the maximum SDM
#' described by Syfert et al. (2014) <doi:10.1016/j.biocon.2014.06.012>. For each increment of 0.01 between a user-specified threshold and the maximum SDM
#' prediction value, the prediction is thresholded to this value to make a binary raster. This raster is then converted
#' to points, which are used to delineate a trial MCP. Each trial MCP is spatially intersected with the original
#' MCP (based on the occurrence coordinates) and the original occurrence points. The Jaccard similarity index is calculated
Expand All @@ -22,10 +22,11 @@
#' # create continuous raster
#' p <- raster::raster(nrows=108, ncols=108, xmn=-50, xmx=50)
#' raster::values(p)<- runif(n = (108*108))
#' raster::crs(p) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
#' # create occurrences
#' xy <- dismo::randomPoints(p, 4)
#' # create original convex hull
#' ch.orig <- mcp(xy)
#' ch.orig <- mcp(xy, crs = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
#' # set threshold
#' thr <- 0.5
#' # mcpSDM
Expand All @@ -36,7 +37,6 @@
mcpSDM <- function(p, xy, ch.orig, thr) {
#require(raster)

options(warn=-1)
vals.p <- raster::getValues(p)
x <- seq(thr, max(vals.p, na.rm=TRUE), 0.01)
jsi.vec <- numeric(length(x))
Expand Down Expand Up @@ -75,6 +75,5 @@ mcpSDM <- function(p, xy, ch.orig, thr) {
i.bestfit <- which(jsi.vec.allPts == max(jsi.vec.allPts))
ch.bestfit <- ch.vec[[i.bestfit]]

options(warn=0)
return(list(jsi = jsi.vec, thr = x, ov.pts = ov.pts.vec, best.fit = ch.bestfit, best.fit.ind = i.bestfit))
}
24 changes: 12 additions & 12 deletions R/ratioOverlap.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' @export

# # # # load r
# r = raster(paste0(system.file(package="changeRangeR"), "/extdata/DemoData/SDM/Forest_suitable_projected1.tif"))
# r = raster(paste0(system.file(package="changeRangeR"), "/extdata/DemoData/SDM/Forest_suitable_projected_coarse.tif"))
# # create random polygon based on r
# mcp <- function (xy) {
# xy <- as.data.frame(coordinates(xy))
Expand All @@ -37,24 +37,24 @@
# xy.bord <- rbind(xy.bord[nrow(xy.bord), ], xy.bord)
# return(SpatialPolygons(list(Polygons(list(Polygon(as.matrix(xy.bord))), 1))))
# }
# rbuf = gBuffer(mcp(dismo::randomPoints(r, 3)), width = 50000)
# rbuf <- gBuffer(mcp(dismo::randomPoints(r, 3)), width = 50000)
# rbuf@proj4string <- crs(r)
# #r = rbuf
# #r <- rbuf
# # load shp and reproject
# shp = readOGR(paste0(system.file(package="changeRangeR", "/extdata/DemoData/shapefiles")), "WDPA_COL_olinguito")
# shp = spTransform(shp, CRS("+proj=utm +zone=18 +south +datum=WGS84 +units=m +no_defs"))
# shp <- readRDS(file.path(system.file(package="changeRangeR", "extdata/DemoData/shapefiles"), "WDPA_COL_olinguito_simp.rds"))
# shp <- spTransform(shp, CRS("+proj=utm +zone=18 +south +datum=WGS84 +units=m +no_defs"))
# # convert shp to raster
# shp = raster::rasterize(shp, r)
# shp <- raster::rasterize(shp, r)
# # Define args
# field = "DESIG_ENG"
# #category = "All"
# category = c("National Natural Park", "Regional Natural Parks", "Integrated Management Regional Districts")
# subfield = TRUE
# field <- "DESIG_ENG"
# #category <- "All"
# category <- c("National Natural Park", "Regional Natural Parks", "Integrated Management Regional Districts")
# subfield <- TRUE
# #test
# t <- ratioOverlap(r, shp, field = field, category = category, subfield= F, quant = c(0.5, 0.75))
# t <- ratioOverlap(r, shp, field = field, category = category, subfield = FALSE, quant = c(0.5, 0.75))
# quant = c(0.25, 0.87)

ratioOverlap <- function(r, shp = NULL, rasMask = NULL, field=NULL, category=NULL, subfield = FALSE, quant = "quartile"){
ratioOverlap <- function(r, shp = NULL, rasMask = NULL, field = NULL, category = NULL, subfield = FALSE, quant = "quartile"){

#setClass("ratioOverlap", slots = list(maskedRange = "RasterLayer", ratio = "character"))
#require(sf)
Expand Down
Binary file removed docs/index.docx
Binary file not shown.
Binary file removed docs/websiteImages/CBC.png
Binary file not shown.
Binary file removed docs/websiteImages/CCNY.png
Binary file not shown.
Binary file removed docs/websiteImages/CUNY.png
Binary file not shown.
Binary file removed docs/websiteImages/GEOBON.png
Binary file not shown.
Binary file removed docs/websiteImages/Humboldt.png
Binary file not shown.
Binary file removed docs/websiteImages/NASA.png
Binary file not shown.
Binary file removed docs/websiteImages/Pace.png
Binary file not shown.
Binary file removed docs/websiteImages/UConn.png
Binary file not shown.
Binary file removed docs/websiteImages/allLogos.png
Binary file not shown.
124 changes: 0 additions & 124 deletions docs/websiteImages/allLogos.svg

This file was deleted.

Binary file removed inst/extdata/DemoData/MODIS/2005_olinguito_Modis.tif
Binary file not shown.
Binary file not shown.
Binary file removed inst/extdata/DemoData/MODIS/2006_olinguito_Modis.tif
Binary file not shown.
Binary file not shown.
Binary file removed inst/extdata/DemoData/MODIS/2008_olinguito_Modis.tif
Binary file not shown.
Binary file not shown.
Binary file removed inst/extdata/DemoData/MODIS/2009_olinguito_Modis.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed inst/extdata/DemoData/SDM/olinguitoSDM.tif
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion inst/extdata/DemoData/shapefiles/WDPA_COL_olinguito.cpg

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion inst/extdata/DemoData/shapefiles/WDPA_COL_olinguito.prj

This file was deleted.

1 change: 0 additions & 1 deletion inst/extdata/DemoData/shapefiles/WDPA_COL_olinguito.qpj

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion inst/extdata/DemoData/shapefiles/vn/VN_NRs.CPG

This file was deleted.

Binary file removed inst/extdata/DemoData/shapefiles/vn/VN_NRs.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion inst/extdata/DemoData/shapefiles/vn/VN_NRs.prj

This file was deleted.

Binary file removed inst/extdata/DemoData/shapefiles/vn/VN_NRs.sbn
Binary file not shown.
Binary file removed inst/extdata/DemoData/shapefiles/vn/VN_NRs.sbx
Binary file not shown.
Binary file removed inst/extdata/DemoData/shapefiles/vn/VN_NRs.shp
Binary file not shown.
2 changes: 0 additions & 2 deletions inst/extdata/DemoData/shapefiles/vn/VN_NRs.shp.xml

This file was deleted.

Binary file removed inst/extdata/DemoData/shapefiles/vn/VN_NRs.shx
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion man/Species-Endemism.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/aooArea.Rd

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

6 changes: 3 additions & 3 deletions man/buildRMM.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/envChange.Rd

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

5 changes: 3 additions & 2 deletions man/mcpSDM.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/ratioOverlap.Rd

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

6 changes: 5 additions & 1 deletion tests/testthat/test_mcpSDM.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
library(sf)

# create continuous raster
p <- raster::raster(nrows=108, ncols=108, xmn=-50, xmx=50)
raster::values(p)<- runif(n = (108*108))
raster::crs(p) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
# create occurrences
xy <- dismo::randomPoints(p, 4)
# create original convex hull
ch.orig <- mcp(xy)
ch.orig <- mcp(xy, crs = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
# set threshold
thr <- 0.5
# mcpSDM
sf_use_s2(FALSE)
out <- mcpSDM(p, xy, ch.orig, thr)


Expand Down
Loading

0 comments on commit 9877d6f

Please sign in to comment.