GithubHelp home page GithubHelp logo

biogeomacro / gift Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 1.0 30.48 MB

:package: R package to extract data from Global Inventory of Floras and Traits (GIFT)

Home Page: https://biogeomacro.github.io/GIFT/

R 100.00%
r r-package biodiversity biodiversity-informatics plants-database plants-distribution

gift's People

Contributors

patrickweigelt avatar pierredenelle avatar rekyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rekyt

gift's Issues

Returned "area" in environmental variable is a character

I've noticed that the "area" column returned by GIFT_env() is a character and not numeric.
It seems to cause no problem to wrap the column into as.numeric() after the fact.

I'm opening this issue to make sure you're aware of the problem.

Here's a reprex:

test_area = GIFT::GIFT_env(1, miscellaneous = "area")

str(test_area)
#> 'data.frame':    1 obs. of  3 variables:
#>  $ entity_ID : chr "1"
#>  $ geo_entity: chr "Ashmore Reef"
#>  $ area      : chr "17.83602"

Created on 2022-12-13 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22 ucrt)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  fr_FR.UTF-8
#>  ctype    fr_FR.UTF-8
#>  tz       Europe/Berlin
#>  date     2022-12-13
#>  pandoc   2.19.2 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.2.0)
#>  class         7.3-20     2022-01-16 [1] CRAN (R 4.2.0)
#>  classInt      0.4-8      2022-09-29 [1] CRAN (R 4.2.1)
#>  cli           3.4.1      2022-09-23 [1] CRAN (R 4.2.1)
#>  DBI           1.1.3      2022-06-18 [1] CRAN (R 4.2.0)
#>  digest        0.6.30     2022-10-18 [1] CRAN (R 4.2.0)
#>  dplyr         1.0.10     2022-09-01 [1] CRAN (R 4.2.1)
#>  e1071         1.7-12     2022-10-24 [1] CRAN (R 4.2.0)
#>  evaluate      0.18       2022-11-07 [1] CRAN (R 4.2.2)
#>  fansi         1.0.3      2022-03-24 [1] CRAN (R 4.2.0)
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.2.0)
#>  fs            1.5.2      2021-12-08 [1] CRAN (R 4.2.0)
#>  generics      0.1.3      2022-07-05 [1] CRAN (R 4.2.0)
#>  GIFT          1.0.0      2022-12-06 [1] Github (BioGeoMacro/GIFT@68487ee)
#>  glue          1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.2.0)
#>  htmltools     0.5.4      2022-12-07 [1] CRAN (R 4.2.2)
#>  jsonlite      1.8.3      2022-10-21 [1] CRAN (R 4.2.0)
#>  KernSmooth    2.23-20    2021-05-03 [1] CRAN (R 4.2.0)
#>  knitr         1.41       2022-11-18 [1] CRAN (R 4.2.0)
#>  lifecycle     1.0.3      2022-10-07 [1] CRAN (R 4.2.1)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
#>  pillar        1.8.1      2022-08-19 [1] CRAN (R 4.2.1)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.2.0)
#>  proxy         0.4-27     2022-06-09 [1] CRAN (R 4.2.0)
#>  purrr         0.3.5      2022-10-06 [1] CRAN (R 4.2.1)
#>  R.cache       0.16.0     2022-07-21 [1] CRAN (R 4.2.1)
#>  R.methodsS3   1.8.2      2022-06-13 [1] CRAN (R 4.2.0)
#>  R.oo          1.25.0     2022-06-12 [1] CRAN (R 4.2.0)
#>  R.utils       2.12.2     2022-11-11 [1] CRAN (R 4.2.0)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.2.0)
#>  Rcpp          1.0.9      2022-07-08 [1] CRAN (R 4.2.1)
#>  reprex        2.0.2      2022-08-17 [1] CRAN (R 4.2.1)
#>  rlang         1.0.6.9000 2022-10-11 [1] Github (r-lib/rlang@28a40b5)
#>  rmarkdown     2.18       2022-11-09 [1] CRAN (R 4.2.2)
#>  rstudioapi    0.14       2022-08-22 [1] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
#>  sf            1.0-9      2022-11-08 [1] CRAN (R 4.2.2)
#>  stringi       1.7.8      2022-07-11 [1] CRAN (R 4.2.1)
#>  stringr       1.5.0      2022-12-02 [1] CRAN (R 4.2.2)
#>  styler        1.8.1      2022-11-07 [1] CRAN (R 4.2.2)
#>  tibble        3.1.8      2022-07-22 [1] CRAN (R 4.2.1)
#>  tidyr         1.2.1      2022-09-08 [1] CRAN (R 4.2.0)
#>  tidyselect    1.2.0      2022-10-10 [1] CRAN (R 4.2.1)
#>  units         0.8-0      2022-02-05 [1] CRAN (R 4.2.0)
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.2.0)
#>  vctrs         0.5.1      2022-11-16 [1] CRAN (R 4.2.0)
#>  withr         2.5.0      2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun          0.35       2022-11-16 [1] CRAN (R 4.2.0)
#>  yaml          2.3.6      2022-10-18 [1] CRAN (R 4.2.0)
#> 
#>  [1] C:/Users/ke76dimu/Documents/R/R-4.2.0/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

API not wrking

I'm getting this error when trying to fetch data.

GIFT_checklists()
Error in value[3L] :
Either the API is wrongly specified or the server is down.

What is a "suitable polygon"? (aka, suit_geo = TRUE)

Hey @patrickweigelt and @pierredenelle,
I'm opening this issue to make it probably more tractable to you, but tell me if you prefer emails.

I'm downloading checklists with GIFT::GIFT_checklist() and I realized there is the suit_geo argument. When I lookup in all the documentation of the package it only states "Is the polygon suitable?". But what it means is explained nowhere (including in the vignettes).
What are "suitable polygons" exactly?
I do see that it heavily influences the number of retrieved checklists:

all_suit_geo = GIFT::GIFT_checklist(
  taxon_name = "Tracheophyta",
  complete_taxon = FALSE,
  floristic_group = "all",
  complete_floristic = FALSE,
  geo_type = "All",
  list_set_only = TRUE,
  suit_geo = FALSE
)
#> Metadata for lists retrieved.
#> GIFT taxonomy downloaded.

only_suit_geo = GIFT::GIFT_checklist(
  taxon_name = "Tracheophyta",
  complete_taxon = FALSE,
  floristic_group = "all",
  complete_floristic = FALSE,
  geo_type = "All",
  list_set_only = TRUE,
  suit_geo = TRUE
)
#> Metadata for lists retrieved.
#> 
#> GIFT taxonomy downloaded.

# More lists with both suitable and non-suitable than with only suitable ones
nrow(all_suit_geo[[1]])
#> [1] 83623
nrow(only_suit_geo[[1]])
#> [1] 45968

Created on 2022-12-12 with reprex v2.0.2

Error with SSL certificate when accessing GIFT from R

Hey :)

I've updated GIFT to the last available version and I'm having trouble because of a recurrent error with SSL certificates (see reprex below).
As this error is triggered when checking the GIFT versions, it means that I cannot perform any query to GIFT as almost all functions check for GIFT versions before performing their queries.
I've checked that it is working when I'm asking explicitly to ignore the SSL certificate.

What's very strange to me is that the "problematic" URL https://gift.uni-goettingen.de/api/index.php?query=versions works very fine in my browser. And when checking the certificate details, it seems fine. I'm no expert there, but maybe you could ask the IT folks that are hosting the GIFT API?

LAST MINUTE EDIT: It seems it may be due to the old age of my computer and OS, because it comes preloaded with certificates to authenticate SSL certificates. When using a browser, the browser uses its own certificates to check authenticity. While when using R, it's using the OS ones, which are quite old in my case. I'll check on another computer and tell you.

LAST MINUTE RE-EDIT: Yes it seems to be caused by my old OS and doesn't cause issues with newer ones. A probable workaround is to manually add the SSL certificate to my OS (I'm unsure how to do that but I'll figure out).

Reprex :

# Load package
library("GIFT")

# Check installed version
sessioninfo::package_info("GIFT", dependencies = FALSE)
#>  package * version date (UTC) lib source
#>  GIFT    * 1.2.0   2023-08-17 [1] CRAN (R 4.2.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2/Resources/library

# Check error
GIFT::GIFT_versions()
#> Warning in open.connection(con, "rb"): URL
#> 'https://gift.uni-goettingen.de/api/index.php?query=versions': statut 'Peer
#> certificate cannot be authenticated with given CA certificates'
#> Error in open.connection(con, "rb"): impossible d'ouvrir la connexion vers 'https://gift.uni-goettingen.de/api/index.php?query=versions'

# Problematic URL
api_request = "https://gift.uni-goettingen.de/api/index.php?query=versions"

# Check with httr
httr::GET(api_request)
#> Error in curl::curl_fetch_memory(url, handle = handle): Peer certificate cannot be authenticated with given CA certificates: [gift.uni-goettingen.de] SSL certificate problem: certificate has expired

# Check with httr2
httr2::req_perform(httr2::request(api_request))
#> Error:
#> ! Peer certificate cannot be authenticated with given CA certificates: [gift.uni-goettingen.de] SSL certificate problem: certificate has expired

#> Backtrace:
#>     ▆
#>  1. └─httr2::req_perform(httr2::request(api_request))
#>  2.   └─base::tryCatch(...)
#>  3.     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  4.       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  5.         └─value[[3L]](cond)

# Check with curl
readLines(curl::curl(api_request))
#> Error in readLines(curl::curl(api_request)): Peer certificate cannot be authenticated with given CA certificates: [gift.uni-goettingen.de] SSL certificate problem: certificate has expired

# Apparently it's a problem with an SSL certificate
# (which seems fine when checking on a browser)

# Ignore SSL certificate
ko = httr2::req_perform(
  httr2::req_options(
    httr2::request(api_request), ssl_verifypeer = 0
  )
)

# Works!
str(httr2::resp_body_json(ko), max.level = 1)
#> List of 5
#>  $ :List of 6
#>  $ :List of 6
#>  $ :List of 6
#>  $ :List of 6
#>  $ :List of 6

Created on 2023-10-04 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23)
#>  os       macOS High Sierra 10.13.6
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  fr_FR.UTF-8
#>  ctype    fr_FR.UTF-8
#>  tz       Europe/Paris
#>  date     2023-10-04
#>  pandoc   2.14.0.3 @ /Applications/RStudio.app/Contents/MacOS/pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date (UTC) lib source
#>  ape                 5.6-2      2022-03-02 [1] CRAN (R 4.1.2)
#>  class               7.3-20     2022-01-16 [1] CRAN (R 4.2.1)
#>  classInt            0.4-8      2022-09-29 [1] CRAN (R 4.2.0)
#>  cli                 3.6.0      2023-01-09 [1] CRAN (R 4.2.0)
#>  clusterGeneration   1.3.7      2020-12-15 [1] CRAN (R 4.0.3)
#>  coda                0.19-4     2020-09-30 [1] CRAN (R 4.0.2)
#>  codetools           0.2-18     2020-11-04 [1] CRAN (R 4.2.1)
#>  combinat            0.0-8      2012-10-29 [1] CRAN (R 4.0.2)
#>  curl                5.0.0      2023-01-12 [1] CRAN (R 4.2.0)
#>  DBI                 1.1.3      2022-06-18 [1] CRAN (R 4.1.2)
#>  digest              0.6.30     2022-10-18 [1] CRAN (R 4.2.0)
#>  dplyr               1.1.0      2023-01-29 [1] CRAN (R 4.2.0)
#>  e1071               1.7-12     2022-10-24 [1] CRAN (R 4.2.0)
#>  evaluate            0.17       2022-10-07 [1] CRAN (R 4.2.0)
#>  expm                0.999-6    2021-01-13 [1] CRAN (R 4.0.3)
#>  fansi               1.0.4      2023-01-22 [1] CRAN (R 4.2.0)
#>  fastmap             1.1.0      2021-01-25 [1] CRAN (R 4.0.3)
#>  fastmatch           1.1-3      2021-07-23 [1] CRAN (R 4.0.3)
#>  fs                  1.5.2      2021-12-08 [1] CRAN (R 4.0.2)
#>  generics            0.1.3      2022-07-05 [1] CRAN (R 4.1.2)
#>  GIFT              * 1.2.0      2023-08-17 [1] CRAN (R 4.2.0)
#>  glue                1.6.2      2022-02-24 [1] CRAN (R 4.1.2)
#>  highr               0.9        2021-04-16 [1] CRAN (R 4.0.3)
#>  htmltools           0.5.3      2022-07-18 [1] CRAN (R 4.1.2)
#>  httr                1.4.4      2022-08-17 [1] CRAN (R 4.1.2)
#>  httr2               0.2.3      2023-05-08 [1] CRAN (R 4.2.0)
#>  igraph              1.3.5      2022-09-22 [1] CRAN (R 4.2.0)
#>  jsonlite            1.8.4      2022-12-06 [1] CRAN (R 4.2.0)
#>  KernSmooth          2.23-20    2021-05-03 [1] CRAN (R 4.2.1)
#>  knitr               1.40       2022-08-24 [1] CRAN (R 4.2.1)
#>  lattice             0.20-45    2021-09-22 [1] CRAN (R 4.2.1)
#>  lifecycle           1.0.3      2022-10-07 [1] CRAN (R 4.2.0)
#>  magrittr            2.0.3      2022-03-30 [1] CRAN (R 4.1.2)
#>  maps                3.4.1      2022-10-30 [1] CRAN (R 4.2.1)
#>  MASS                7.3-58.1   2022-08-03 [1] CRAN (R 4.2.0)
#>  Matrix              1.5-1      2022-09-13 [1] CRAN (R 4.2.0)
#>  mnormt              2.1.1      2022-09-26 [1] CRAN (R 4.2.0)
#>  nlme                3.1-160    2022-10-10 [1] CRAN (R 4.2.0)
#>  numDeriv            2016.8-1.1 2019-06-06 [1] CRAN (R 4.0.2)
#>  optimParallel       1.0-2      2021-02-11 [1] CRAN (R 4.2.0)
#>  phangorn            2.10.0     2022-09-18 [1] CRAN (R 4.2.0)
#>  phytools            1.2-0      2022-09-01 [1] CRAN (R 4.2.0)
#>  pillar              1.8.1      2022-08-19 [1] CRAN (R 4.1.2)
#>  pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.0.2)
#>  plotrix             3.8-2      2021-09-08 [1] CRAN (R 4.0.2)
#>  proxy               0.4-27     2022-06-09 [1] CRAN (R 4.1.2)
#>  purrr               1.0.1      2023-01-10 [1] CRAN (R 4.2.0)
#>  quadprog            1.5-8      2019-11-20 [1] CRAN (R 4.0.2)
#>  R.cache             0.16.0     2022-07-21 [1] CRAN (R 4.1.2)
#>  R.methodsS3         1.8.2      2022-06-13 [1] CRAN (R 4.1.2)
#>  R.oo                1.25.0     2022-06-12 [1] CRAN (R 4.1.2)
#>  R.utils             2.12.1     2022-10-30 [1] CRAN (R 4.2.1)
#>  R6                  2.5.1      2021-08-19 [1] CRAN (R 4.0.2)
#>  rappdirs            0.3.3      2021-01-31 [1] CRAN (R 4.0.2)
#>  Rcpp                1.0.10     2023-01-22 [1] CRAN (R 4.2.0)
#>  reprex              2.0.2      2022-08-17 [1] CRAN (R 4.1.2)
#>  rlang               1.0.6      2022-09-24 [1] CRAN (R 4.2.0)
#>  rmarkdown           2.17       2022-10-07 [1] CRAN (R 4.2.0)
#>  rstudioapi          0.14       2022-08-22 [1] CRAN (R 4.1.2)
#>  scatterplot3d       0.3-42     2022-09-08 [1] CRAN (R 4.2.0)
#>  sessioninfo         1.2.2      2021-12-06 [1] CRAN (R 4.0.2)
#>  sf                  1.0-8      2022-07-14 [1] CRAN (R 4.1.2)
#>  stringi             1.7.12     2023-01-11 [1] CRAN (R 4.2.0)
#>  stringr             1.5.0      2022-12-02 [1] CRAN (R 4.2.0)
#>  styler              1.8.0      2022-10-22 [1] CRAN (R 4.2.0)
#>  tibble              3.1.8      2022-07-22 [1] CRAN (R 4.1.2)
#>  tidyr               1.3.0      2023-01-24 [1] CRAN (R 4.2.0)
#>  tidyselect          1.2.0      2022-10-10 [1] CRAN (R 4.2.0)
#>  units               0.8-0      2022-02-05 [1] CRAN (R 4.1.2)
#>  utf8                1.2.3      2023-01-31 [1] CRAN (R 4.2.0)
#>  vctrs               0.5.2      2023-01-23 [1] CRAN (R 4.2.0)
#>  withr               2.5.0      2022-03-03 [1] CRAN (R 4.1.2)
#>  xfun                0.34       2022-10-18 [1] CRAN (R 4.2.0)
#>  yaml                2.3.6      2022-10-18 [1] CRAN (R 4.2.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Timeout with big downloads

This is more of a suggestion than an issue, but I have found that increasing the timeout:
options(timeout = max(1000, getOption("timeout")))

makes it easier to complete larger downloads.

Error in readBin when trying to get traits data

Hello,

I try to get data from the GIFT_traits function, as described in the Get Started tutorial, but it seems to have a bug.

I can't generate the first object (generated by the following code : height <- GIFT_traits(trait_IDs = c("1.6.2"), agreement = 0.66,
bias_ref = FALSE, bias_deriv = FALSE)
)

Here, I get this error :

Error in readBin(3L, raw(0), 32768L) : cannot read from connection
In addition: Warning message:
In readBin(3L, raw(0), 32768L) :
URL 'https://gift.uni-goettingen.de/api/extended/index3.1.php?query=species&startat=200000': Timeout of 60 seconds was reached

How can I fix it ? Is it because of a bug in the API key ? Or is it because of the quality of my internet connection ?

Thank you in advance for you help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.