Skip to content

Commit

Permalink
Merge pull request #45 from adamlilith/solstice_2022_2023
Browse files Browse the repository at this point in the history
Removed dependency on `geodata` and `MuMin`
  • Loading branch information
adamlilith authored Jun 21, 2024
2 parents 4c172bd + 0b93d28 commit 0148f00
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 57 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -54,8 +54,6 @@ Imports:
stats,
terra,
utils
Suggests:
geodata
LazyData: true
LazyLoad: yes
URL: https://github.com/adamlilith/enmSdmX
Expand Down
22 changes: 22 additions & 0 deletions R/canada.r
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions R/enmSdmX.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added inst/extdata/canada_level0_gadm41.gpkg
Binary file not shown.
24 changes: 24 additions & 0 deletions man/canada.Rd

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

43 changes: 16 additions & 27 deletions man/customAlbers.Rd

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

1 change: 1 addition & 0 deletions man/enmSdmX.Rd

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

43 changes: 16 additions & 27 deletions man/examples/customCRS_examples.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library(sf)

# Madagascar
### Madagascar
data(mad0)

alb <- customAlbers(mad0)
Expand All @@ -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)

0 comments on commit 0148f00

Please sign in to comment.