Skip to content

Commit

Permalink
version 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredenelle authored and cran-robot committed Feb 28, 2024
1 parent 711d71b commit d778cf6
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 49 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: GIFT
Type: Package
Title: Access to the Global Inventory of Floras and Traits (GIFT)
Version: 1.3.1
Version: 1.3.2
Authors@R: c(
person("Pierre", "Denelle", email = "pierre.denelle@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5037-2281")),
Expand Down Expand Up @@ -31,9 +31,9 @@ URL: https://github.com/BioGeoMacro/GIFT,
BugReports: https://github.com/BioGeoMacro/GIFT/issues
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2024-01-08 21:09:07 UTC; Pierre
Packaged: 2024-02-27 10:03:00 UTC; Pierre
Author: Pierre Denelle [aut, cre] (<https://orcid.org/0000-0001-5037-2281>),
Patrick Weigelt [aut] (<https://orcid.org/0000-0002-2485-3708>)
Maintainer: Pierre Denelle <pierre.denelle@gmail.com>
Repository: CRAN
Date/Publication: 2024-01-09 02:10:02 UTC
Date/Publication: 2024-02-27 10:50:02 UTC
26 changes: 13 additions & 13 deletions MD5
@@ -1,13 +1,13 @@
99d54072f7d8c5314608da661765a5f0 *DESCRIPTION
4ca1d828d77d703ad79549b03188bc60 *DESCRIPTION
729d122d2d4c333f243fca6bda30cc11 *NAMESPACE
0150e571b883de95e476bcabda1cd1ad *NEWS.md
aa907f4abefb5e0310c56c7d217692e4 *NEWS.md
fc6db48a95772ef9331f9f853b2e02b6 *R/GIFT_checklists.R
3e084469221739db88f54b53d0b2ff83 *R/GIFT_checklists_conditional.R
fe6ad55fa563781dcf685145e0af019c *R/GIFT_checklists_raw.R
b522a4a0d4d59621d9c0be39dbe8955d *R/GIFT_coverage.R
4fea0753771dc4f0c997c12dd53c69bf *R/GIFT_env.R
13cd89cd641aeb1ffd0a7fb687de2f31 *R/GIFT_env_meta_misc.R
fa70b408864df69f710a0fc86e9316ff *R/GIFT_env_meta_raster.R
a2f464840a6df704404c7af0c464735f *R/GIFT_env_meta_misc.R
30a51f5980426ac4bf473a2365dfb154 *R/GIFT_env_meta_raster.R
aa24fd4e3c07223294d80ce819548fed *R/GIFT_lists.R
3301682c59ed182c588efba783ed8ca6 *R/GIFT_no_overlap.R
ad2853f0dfcd1bdf04dcbb6b0a33463a *R/GIFT_overlap.R
Expand All @@ -16,7 +16,7 @@ ad2853f0dfcd1bdf04dcbb6b0a33463a *R/GIFT_overlap.R
a578c86815fd892e4b5519216d69b47e *R/GIFT_regions.R
b68aeab9cff5d84484beb7fa1a46ad79 *R/GIFT_richness.R
aaa158337b77d9c2c60638968c45da91 *R/GIFT_shapes.R
fb043c8989791684e5e4936256f4304d *R/GIFT_spatial.R
97bc0c2e332b1c0b5a7d0c1105918518 *R/GIFT_spatial.R
5ceb4be1793fcee0e2077db9c173206e *R/GIFT_species.R
08f25cc9b845e392bc6bc95d44a63df6 *R/GIFT_species_distribution.R
2187b7db11480523a1b7366c15f8b53a *R/GIFT_species_lookup.R
Expand All @@ -27,23 +27,23 @@ fb043c8989791684e5e4936256f4304d *R/GIFT_spatial.R
3eafc139ba28c47616fa6a087e5dae1c *R/GIFT_traits_raw.R
fe8315d3934a893e50ec63bba96bbfe6 *R/GIFT_traits_tax.R
1240e335ae592a6b79af6980dadb8db5 *R/GIFT_versions.R
15b0f4988b97e672bb8411d89181cc6c *R/check_functions.R
2d06d22014c1015436d76d29f0bc3d53 *R/check_functions.R
d478f4e0b13f11f6059e82ac27aa0243 *R/figures_vignette.R
1319b7ae28fb531c98be7d5f79be1eac *R/function_dependency.R
629d794dd2bd4c7dc67f5acd3fb332e4 *R/pkg_check.R
f81eaa1c946a8cb8766652b8c9886f4f *R/western_mediterranean.R
19c9307ec04bb183020abab0d34c6805 *README.md
70b52af4591ea58d1130d15fdd60aa60 *build/vignette.rds
61fca6d5bfe61d0cdb98a388172528e5 *data/western_mediterranean.rda
081787ac72ba5c66614abfc75b5e347a *inst/doc/GIFT.R
8be63e6c331ade1fa9f44e2961f4fca6 *inst/doc/GIFT.Rmd
91772ccf46b231dcbe547d26acdd9b25 *inst/doc/GIFT.html
811f3a2d555320864a7d2572bb5418e3 *inst/doc/GIFT.R
154941e82866de24a353960550ce6cc4 *inst/doc/GIFT.Rmd
c729c1bda2db59b5aa0b89b3e8d5ec33 *inst/doc/GIFT.html
5489dd8c667ea2cad5a0626bb7647b35 *inst/doc/GIFT_API.R
b884898c064d14ff0753b1a5d30e736a *inst/doc/GIFT_API.Rmd
24b27d914b50fa1a80a365dcce52df25 *inst/doc/GIFT_API.html
6e58d085cf0f58244e258bdecb077fdd *inst/doc/GIFT_API.html
2f19840804d66320978e314b7027d353 *inst/doc/GIFT_advanced_users.R
e02f1f602be481afddae7962126eb813 *inst/doc/GIFT_advanced_users.Rmd
f013a7a026cd96954bf2bc98ac788ea6 *inst/doc/GIFT_advanced_users.html
785b4d2c43fd3fa4079ec251537ce09b *inst/doc/GIFT_advanced_users.html
8d69b7ea88ecb2c6a423ac04603a598a *man/GIFT_checklists.Rd
dcbe04400d4eb025d35ebf5ff16f071c *man/GIFT_checklists_conditional.Rd
91188371b273d0a5cbe632f32314593a *man/GIFT_checklists_raw.Rd
Expand All @@ -59,7 +59,7 @@ f9e6455e87b01c0c8bcc046c0696806d *man/GIFT_no_overlap.Rd
094c397ed3ea3d70659091eb5a324fb4 *man/GIFT_regions.Rd
49b7f0c02144d26cdbf0fe15380fc55f *man/GIFT_richness.Rd
8a7b6898e2c9a9e9aa5d02fa3362899d *man/GIFT_shapes.Rd
644c831df365092073468a8b28210e28 *man/GIFT_spatial.Rd
60f5f8d5a674ab9538612c298fd30dd2 *man/GIFT_spatial.Rd
327243489a95d20acda89f3aef56d96c *man/GIFT_species.Rd
e9b15687d62b977497694f3505ea5e1a *man/GIFT_species_distribution.Rd
15226ca28dafe17fd91a5adf50d2c699 *man/GIFT_species_lookup.Rd
Expand Down Expand Up @@ -120,6 +120,6 @@ eea57da0e5771d4b67e0b9112b03436c *tests/testthat/test-GIFT_species_distribution.
6fff45280cfcc80aba5e4cce313aef6b *tests/testthat/test-GIFT_traits_raw.R
c096c4ac48a58f5f738a75be41bce8d1 *tests/testthat/test-GIFT_traits_tax.R
28acd92149932c19c840426112697ca7 *tests/testthat/test-GIFT_versions.R
8be63e6c331ade1fa9f44e2961f4fca6 *vignettes/GIFT.Rmd
154941e82866de24a353960550ce6cc4 *vignettes/GIFT.Rmd
b884898c064d14ff0753b1a5d30e736a *vignettes/GIFT_API.Rmd
e02f1f602be481afddae7962126eb813 *vignettes/GIFT_advanced_users.Rmd
10 changes: 10 additions & 0 deletions NEWS.md
@@ -1,5 +1,15 @@
# GIFT

# GIFT 1.3.2
## Minor changes

* Better description of entity_ID argument in GIFT_spatial
* Example added in GIFT_spatial
* Main vignette: detail added regarding the version of GIFT used for the
species distribution, packages edited in the beginning
* Function check_query() added in the check_functions and implemented in
GITT_env_meta_raster() and GIFT_env_meta_misc()

# GIFT 1.3.1
## Minor changes

Expand Down
6 changes: 6 additions & 0 deletions R/GIFT_env_meta_misc.R
Expand Up @@ -49,6 +49,9 @@ GIFT_env_meta_misc <- function(
GIFT_version <- check_gift_version(GIFT_version)

# Return the miscellaneous environmental information as a data frame
check_query(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=env_misc"))
tmp <- jsonlite::read_json(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=env_misc"), simplifyVector = TRUE)
Expand All @@ -58,6 +61,9 @@ GIFT_env_meta_misc <- function(
tmp$citavi_ID <- substr(tmp$citavi_ID, 1, (nchar(tmp$citavi_ID)-1))

# Merging complete reference names
check_query(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=references_citavi"))
refs <- jsonlite::read_json(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=references_citavi"), simplifyVector = TRUE)
Expand Down
6 changes: 6 additions & 0 deletions R/GIFT_env_meta_raster.R
Expand Up @@ -53,6 +53,9 @@ GIFT_env_meta_raster <- function(
GIFT_version <- check_gift_version(GIFT_version)

# Return the raster environmental information
check_query(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=env_raster"))
tmp <- jsonlite::read_json(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=env_raster"), simplifyVector = TRUE)
Expand All @@ -61,6 +64,9 @@ GIFT_env_meta_raster <- function(
tmp$citavi_ID <- gsub("^.*\\#", "", tmp$citavi_ID)
tmp$citavi_ID <- substr(tmp$citavi_ID, 1, (nchar(tmp$citavi_ID)-1))

check_query(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=references_citavi"))
refs <- jsonlite::read_json(paste0(
api, "index", ifelse(GIFT_version == "beta", "", GIFT_version),
".php?query=references_citavi"), simplifyVector = TRUE)
Expand Down
13 changes: 12 additions & 1 deletion R/GIFT_spatial.R
Expand Up @@ -16,7 +16,9 @@
#' `extent_intersect` means that every polygon from GIFT for which the extent
#' intersects the provided shape/coordinates will be retrieved.
#'
#' @param entity_ID List of entity_ID to retrieve.
#' @param entity_ID Constrain the list of regions to be received by a
#' predefined set of entity_IDs. E.g. this list could come from
#' GIFT_checklists_conditional().
#'
#' @template GIFT_version_api
#'
Expand All @@ -39,22 +41,31 @@
#'
#' @examples
#' \donttest{
#' # With a shapefile
#' data("western_mediterranean")
#' ex <- GIFT_spatial(shp = western_mediterranean, overlap = "centroid_inside")
#'
#' # With a shapefile coming from GIFT
#' spain <- GIFT_shapes(entity_ID = 10071)
#' ex_spain <- GIFT_spatial(shp = spain)
#'
#' # With a point
#' custom_point <- cbind(9.9, 51)
#' ex2 <- GIFT_spatial(coordinates = custom_point,
#' overlap = "extent_intersect")
#'
#' # With an extent
#' custom_extent <- cbind(c(-13, -18), c(27.5, 29.3))
#' ex3 <- GIFT_spatial(coordinates = custom_extent,
#' overlap = "extent_intersect")
#'
#' # With a custom polygon
#' custom_polygon <- cbind(c(-18, -16.9, -13, -13, -18, -18),
#' c(29.3, 33, 29.3, 27.5, 27.5, 29.3))
#' ex4 <- GIFT_spatial(coordinates = custom_polygon,
#' overlap = "extent_intersect")
#'
#' #With a linestring
#' custom_linestring <- rbind(c(9.9, 51), c(2.35, 48.9))
#' custom_linestring <- sf::st_as_sf(as.data.frame(custom_linestring),
#' coords = c("V1", "V2"))
Expand Down
47 changes: 47 additions & 0 deletions R/check_functions.R
Expand Up @@ -474,6 +474,53 @@ check_overlap_threshold <- function(overlap_threshold) {
}
}

# Checking manual queries
#
# Authors: Pierre Denelle
#
# Stop if api argument does not have the right format
#
# Args:
# api a character
#
# Returns:
# nothing, shows an error message

# Run the API and see if we get 'no query selected'
check_query <- function(api) {
if(length(api) != 1 || !is.character(api)){
stop("api must be a character string indicating which API to use.")
}

# First check: internet connection
if(!curl::has_internet()) {
message("No internet connection found.")
return(NULL)
}

# Second check: web API available
req <- httr2::request(api)
resp <- httr2::req_error(req, is_error = function(resp) FALSE)

# test for non-existing APIs
tryCatch(expr = httr2::req_perform(resp),
error = function(expr) {
message(
"Either the API is wrongly specified or the server is down.")
return(NULL)
})

# If the server was found, check for status
resp_status <- httr2::resp_status_desc(httr2::req_perform(resp))
if(resp_status == "Unauthorized"){
message("A password is needed for this restricted API.")
return(NULL)
} else if(resp_status != "OK"){
message("Either the API is wrongly specified or the server is down.")
return(NULL)
}
}

# Checking ref_excluded argument
#
# Authors: Pierre Denelle
Expand Down
7 changes: 6 additions & 1 deletion inst/doc/GIFT.R
Expand Up @@ -15,6 +15,7 @@ suppressPackageStartupMessages({
library("rnaturalearthdata")
library("tidyr")
library("ape")
library("patchwork")
})
})

Expand All @@ -27,11 +28,14 @@ knitr::include_graphics("../man/figures/GIFT.png")
## ----echo=TRUE, eval=FALSE----------------------------------------------------
# library("GIFT")
# library("dplyr")
# library("knitr")
# library("kableExtra")
# library("ggplot2")
# library("sf")
# library("rnaturalearth")
# library("rnaturalearthdata")
# library("tidyr")
# library("ape")
# library("patchwork")

## ----echo = TRUE, eval = FALSE------------------------------------------------
Expand Down Expand Up @@ -236,7 +240,8 @@ kable(anemone_lookup, "html") %>%

## -----------------------------------------------------------------------------
anemone_distr <- GIFT_species_distribution(
genus = "Anemone", epithet = "nemorosa", aggregation = TRUE)
genus = "Anemone", epithet = "nemorosa", aggregation = TRUE,
GIFT_version = "2.2")

anemone_statuses <- anemone_distr %>%
mutate(native = ifelse(native == 1, "native", "non-native"),
Expand Down
7 changes: 6 additions & 1 deletion inst/doc/GIFT.Rmd
Expand Up @@ -35,6 +35,7 @@ suppressPackageStartupMessages({
library("rnaturalearthdata")
library("tidyr")
library("ape")
library("patchwork")
})
})
Expand Down Expand Up @@ -69,11 +70,14 @@ The following R packages are required to build this vignette:
```{r, echo=TRUE, eval=FALSE}
library("GIFT")
library("dplyr")
library("knitr")
library("kableExtra")
library("ggplot2")
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
library("tidyr")
library("ape")
library("patchwork")
```

Expand Down Expand Up @@ -529,7 +533,8 @@ more details.

```{r}
anemone_distr <- GIFT_species_distribution(
genus = "Anemone", epithet = "nemorosa", aggregation = TRUE)
genus = "Anemone", epithet = "nemorosa", aggregation = TRUE,
GIFT_version = "2.2")
anemone_statuses <- anemone_distr %>%
mutate(native = ifelse(native == 1, "native", "non-native"),
Expand Down

0 comments on commit d778cf6

Please sign in to comment.