diff --git a/DESCRIPTION b/DESCRIPTION index 5c93a69..b89142c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: enmSdmX Type: Package Title: Species Distribution Modeling and Ecological Niche Modeling Version: 1.1.6 -Date: 2024-06-06 +Date: 2024-06-13 Authors@R: c( person( @@ -54,8 +54,6 @@ Imports: stats, terra, utils -Suggests: - geodata LazyData: true LazyLoad: yes URL: https://github.com/adamlilith/enmSdmX diff --git a/R/canada.r b/R/canada.r new file mode 100644 index 0000000..61378db --- /dev/null +++ b/R/canada.r @@ -0,0 +1,22 @@ +#' @name canada +#' +#' @title Vector outline of Canada +#' +#' @description This \code{SpatVector} represents the outline of Canada in WGS84 (unprojected) coordinates. This is the "low resolution" (less accurate) version from GADM. +#' +#' @docType data +#' +#' @format An object of class \code{'SpatVector'}. +#' +#' @keywords Canada +#' +#' @source \href{https://gadm.org/index.html}{Database of Global Administrative Areas (GADM)} +#' +#' @examples +#' +#' library(terra) +#' canFile <- system.file('extdata', 'canada_level0_gadm41.gpkg', package='enmSdmX') +#' canada <- vect(canFile) +#' plot(canada) +#' +NULL diff --git a/R/enmSdmX.r b/R/enmSdmX.r index 032af24..b71c968 100644 --- a/R/enmSdmX.r +++ b/R/enmSdmX.r @@ -75,6 +75,7 @@ #' \code{\link{spatVectorToSpatial}}: Convert \code{SpatVector} object to a \code{Spatial}* object. \cr #' #' @section Data: +#' \code{\link{canada}}: Outline of Canada \cr #' \code{\link{lemurs}}: Lemur occurrences \cr #' \code{\link{mad0}}: Madagascar spatial object \cr #' \code{\link{mad1}}: Madagascar spatial object \cr diff --git a/inst/extdata/canada_level0_gadm41.gpkg b/inst/extdata/canada_level0_gadm41.gpkg new file mode 100644 index 0000000..b03365b Binary files /dev/null and b/inst/extdata/canada_level0_gadm41.gpkg differ diff --git a/man/canada.Rd b/man/canada.Rd new file mode 100644 index 0000000..f5d9c85 --- /dev/null +++ b/man/canada.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/canada.r +\docType{data} +\name{canada} +\alias{canada} +\title{Vector outline of Canada} +\format{ +An object of class \code{'SpatVector'}. +} +\source{ +\href{https://gadm.org/index.html}{Database of Global Administrative Areas (GADM)} +} +\description{ +This \code{SpatVector} represents the outline of Canada in WGS84 (unprojected) coordinates. This is the "low resolution" (less accurate) version from GADM. +} +\examples{ + +library(terra) +canFile <- system.file('extdata', 'canada_level0_gadm41.gpkg', package='enmSdmX') +canada <- vect(canFile) +plot(canada) + +} +\keyword{Canada} diff --git a/man/customAlbers.Rd b/man/customAlbers.Rd index 384e301..a769013 100644 --- a/man/customAlbers.Rd +++ b/man/customAlbers.Rd @@ -39,7 +39,7 @@ Please note that these are \emph{NOT} standard projections, so do not have an EP \examples{ library(sf) -# Madagascar +### Madagascar data(mad0) alb <- customAlbers(mad0) @@ -59,43 +59,32 @@ plot(st_geometry(madVert), main='Vertical') par(oldPar) -\donttest{ +### Canada # The effect is more noticeable when plotting large areas, # especially if they lie near the poles. # This example can take a few minutes to run and plot. -library(geodata) library(terra) -# Get outline of Canada... -# We wrap this in tryCatch() in case the server is down. -can <- tryCatch( - gadm('CAN', level=0, path=tempdir(), resolution=2), - error=function(cond) FALSE -) +canFile <- system.file('extdata', 'canada_level0_gadm41.gpkg', package='enmSdmX') +can <- vect(canFile) -if (!is.logical(can)) { +alb <- customAlbers(can) +lamb <- customLambert(can) +vert <- customVNS(can) - alb <- customAlbers(can) - lamb <- customLambert(can) - vert <- customVNS(can) +canAlb <- project(can, alb) +canLamb <- project(can, lamb) +canVert <- project(can, vert) - canAlb <- project(can, alb) - canLamb <- project(can, lamb) - canVert <- project(can, vert) - - oldPar <- par(mfrow=c(2, 2)) +oldPar <- par(mfrow=c(2, 2)) - plot(can, main='Unprojected (WGS84)') - plot(canAlb, main='Albers') - plot(canLamb, main='Lambert') - plot(canVert, main='Vertical') - - par(oldPar) +plot(can, main='Unprojected (WGS84)') +plot(canAlb, main='Albers') +plot(canLamb, main='Lambert') +plot(canVert, main='Vertical') -} - -} +par(oldPar) } \seealso{ \code{\link{getCRS}}, \code{\link{customAlbers}}, \code{\link{customLambert}}, \code{\link{customVNS}} diff --git a/man/enmSdmX.Rd b/man/enmSdmX.Rd index d1a83f8..a8a3175 100644 --- a/man/enmSdmX.Rd +++ b/man/enmSdmX.Rd @@ -102,6 +102,7 @@ Create an issue on \href{https://github.com/adamlilith/enmSdmX/issues}{GitHub}. \section{Data}{ + \code{\link{canada}}: Outline of Canada \cr \code{\link{lemurs}}: Lemur occurrences \cr \code{\link{mad0}}: Madagascar spatial object \cr \code{\link{mad1}}: Madagascar spatial object \cr diff --git a/man/examples/customCRS_examples.r b/man/examples/customCRS_examples.r index bb86953..2fd4f14 100644 --- a/man/examples/customCRS_examples.r +++ b/man/examples/customCRS_examples.r @@ -1,6 +1,6 @@ library(sf) -# Madagascar +### Madagascar data(mad0) alb <- customAlbers(mad0) @@ -20,40 +20,29 @@ plot(st_geometry(madVert), main='Vertical') par(oldPar) -\donttest{ +### Canada # The effect is more noticeable when plotting large areas, # especially if they lie near the poles. # This example can take a few minutes to run and plot. -library(geodata) library(terra) -# Get outline of Canada... -# We wrap this in tryCatch() in case the server is down. -can <- tryCatch( - gadm('CAN', level=0, path=tempdir(), resolution=2), - error=function(cond) FALSE -) +canFile <- system.file('extdata', 'canada_level0_gadm41.gpkg', package='enmSdmX') +can <- vect(canFile) -if (!is.logical(can)) { +alb <- customAlbers(can) +lamb <- customLambert(can) +vert <- customVNS(can) - alb <- customAlbers(can) - lamb <- customLambert(can) - vert <- customVNS(can) +canAlb <- project(can, alb) +canLamb <- project(can, lamb) +canVert <- project(can, vert) - canAlb <- project(can, alb) - canLamb <- project(can, lamb) - canVert <- project(can, vert) - - oldPar <- par(mfrow=c(2, 2)) +oldPar <- par(mfrow=c(2, 2)) - plot(can, main='Unprojected (WGS84)') - plot(canAlb, main='Albers') - plot(canLamb, main='Lambert') - plot(canVert, main='Vertical') - - par(oldPar) +plot(can, main='Unprojected (WGS84)') +plot(canAlb, main='Albers') +plot(canLamb, main='Lambert') +plot(canVert, main='Vertical') -} - -} +par(oldPar)