Giter Site home page Giter Site logo

ropensci / rredlist Goto Github PK

View Code? Open in Web Editor NEW
44.0 10.0 14.0 1.67 MB

IUCN Red List API Client

Home Page: https://docs.ropensci.org/rredlist

License: Other

R 98.38% Makefile 1.62%
conservation api-wrapper biodiversity rstats iucn-red-list iucn r r-package taxize

rredlist's Introduction

rredlist

cran version cran status R-check codecov.io rstudio mirror downloads

rredlist is an R client for the IUCN Red List (https://apiv3.iucnredlist.org/api/v3/docs). The IUCN Red List is a global list of threatened and endangered species. IUCN Red List docs: https://apiv3.iucnredlist.org/api/v3/docs

Installation

CRAN

install.packages("rredlist")

Development version

remotes::install_github("ropensci/rredlist")
# OR
install.packages("rredlist", repos="https://dev.ropensci.org")

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for rredlist in R doing citation(package = 'rredlist')
  • Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

rofooter

rredlist's People

Contributors

maelle avatar sckott avatar willgearty avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rredlist's Issues

$result is list() and NULL

Session Info
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rredlist_0.4.0 taxize_0.9.2   xlsx_0.5.7     xlsxjars_0.6.1 rJava_0.9-9   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.15      xml2_1.1.1        magrittr_1.5      ape_5.0           lattice_0.20-35  
 [6] R6_2.2.2          rlang_0.2.0       foreach_1.4.3     stringr_1.2.0     httr_1.3.1       
[11] plyr_1.8.4        tools_3.4.3       parallel_3.4.3    bold_0.5.0        grid_3.4.3       
[16] data.table_1.10.4 nlme_3.1-131      iterators_1.0.8   yaml_2.1.14       httpcode_0.2.0   
[21] tibble_1.4.2      reshape2_1.4.2    codetools_0.2-15  triebeard_0.3.0   curl_2.8.1       
[26] crul_0.4.0        mime_0.5          stringi_1.1.5     pillar_1.2.1      compiler_3.4.3   
[31] urltools_1.6.0    jsonlite_1.5      reshape_0.8.7     zoo_1.8-0  

EDIT: Whoops, my fault - the test species I used happened to be synonyms that didn't return results from IUCN! Ignore the below!

Thanks for a great tool. Since I last used the package, something seems to have changed, as the $result element now returns NULL. See below.

> results<-rl_search(name = "Artocarpus rigidus", key = key, verbose = TRUE)
* Found bundle for host apiv3.iucnredlist.org: 0x46d9a620 [can pipeline]
* Re-using existing connection! (#17) with host apiv3.iucnredlist.org
* Connected to apiv3.iucnredlist.org (176.58.126.20) port 80 (#17)
> GET /api/v3/species/Artocarpus%20rigidus?token=HIDDEN HTTP/1.1
Host: apiv3.iucnredlist.org
User-Agent: libcurl/7.54.1 r-curl/2.8.1 crul/0.4.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*

< HTTP/1.1 200 OK
< Server: nginx/1.1.19
< Date: Sun, 11 Mar 2018 08:32:26 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 41
< Connection: keep-alive
< X-Powered-By: Sails <sailsjs.org>
* Added cookie sails.sid="s%3AHglE_b-TyiEDpz-H7hPxz_Xq.Ko3gdIu10LW2aI%2BOYLa1Tfa9ususo7d5WWDwOqGchw8" for domain apiv3.iucnredlist.org, path /, expire 0
< Set-Cookie: sails.sid=s%3AHglE_b-TyiEDpz-H7hPxz_Xq.Ko3gdIu10LW2aI%2BOYLa1Tfa9ususo7d5WWDwOqGchw8; Path=/; HttpOnly
< Vary: Accept-Encoding
< 
* Connection #17 to host apiv3.iucnredlist.org left intact
> results
$name
[1] "Artocarpus rigidus"

$result
list()

I have used two different API keys, one I know was working previously, and a new one (that has been idle for a few months). I did iterate through several hundred species on the first run (with an error in the code meaning I can see if the first few worked), but even several minutes to half an hour later I get the same result.

Increase test coverage?

It might be a good issue for a new contributor.

E.g. rl_sp.R has no test but tests could be added using other examples?

rl_habitats or rl_habitats_ ?

Hello,

Could I ask what is the difference between rl_habitats and rl_habitats_ ?
Is the logic similar to the wm_attr_data and the wm_attr_data_ of the worrms package?
I would like to search for multiple species at once. I have extracted the species names in a (character) list, but it doesn't seem to work.
I get the error

Error: name must be length 1

both when I run

species_IUCN <- rl_habitats(species_list)

as well as when I run

species_IUCN <- rl_habitats_(species_list)

Also, how can I get a Redlist API key? I saw this issue #52 but I don't think it has been solved by now.

I am using R 4.1.1. and rredlist 0.7.1

Best,

Christina

Function to retrieve all species list

A major use for me is creating species lists by their upper taxonomy. To that end, I use this function frequently to retrieve a full species list with taxonomic information that I can then filter to a certain taxa group. Not sure if this is possible elsewhere in the package? I'm sure there is a way to clean or simplify this function to accommodate if the database changes-- current count is at 93,872.

rl_sp_all <- function(k){
    pg0 <- rl_sp(page=0, key = k)
    pg1 <-  rl_sp(page=1, key = k)
    pg2 <-  rl_sp(page=2, key = k)
    pg3 <-  rl_sp(page=3, key = k)
    pg4 <-  rl_sp(page=4, key = k)
    pg5 <-  rl_sp(page=5, key = k)
    pg6 <-  rl_sp(page=6, key = k)
    pg7 <-  rl_sp(page=7, key = k)
    pg8 <-  rl_sp(page=8, key = k)
    pg9 <-  rl_sp(page=9, key = k)
    all_pages <- rbind(pg0$result,pg1$result, pg2$result, pg3$result,pg4$result, pg5$result, pg6$result, pg7$result,  pg8$result,pg9$result)
}

API vs Website again

I see the previous discussion on the API vs Website issue. I am encountering that as well. For the order I am looking at, we pulled country level occurrence data from the website and from the API. API returns a lower species count in most cases.

For example: "Nyassunio nyassaensis" occurs in 3 countries according to the website while
rl_occ_country("Nyassunio nyassaensis",key=IUCN_REDLIST_KEY)
returns no occurrences.

I guess I just want to understand why the website and API differ?

Collate subheading information from Habitat & Ecology

I suspect that by Red List API, this does not currently seem possible. But there are several subheadings in the "Habitat and Ecology" section that do not appear accessible via the package, when downloading rl_narrative or rl_search. Particularly: SYSTEM, HABITAT TYPE, GENERATION LENGTH (YEARS), CONGREGATORY, MOVEMENT PATTERNS, CONTINUING DECLINE IN AREA, EXTENT AND/OR QUALITY OF HABITAT

Has this come up before?

Bad Gateway (HTTP 502) error when trying to get country occurrence data

Session Info
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rredlist_0.4.0    data.table_1.10.4 dplyr_0.5.0       rCAT_0.1.5        rgdal_1.2-7       jsonlite_1.5      rgbif_0.9.8       raster_2.5-8     
[9] sp_1.2-4         

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10     xml2_1.1.1       whisker_0.3-2    magrittr_1.5     munsell_0.4.3    colorspace_1.3-2 lattice_0.20-34  R6_2.2.0         quadprog_1.5-5  
[10] rlang_0.1.2      stringr_1.2.0    httr_1.2.1       plyr_1.8.4       tools_3.3.3      parallel_3.3.3   grid_3.3.3       geoaxe_0.1.0     gtable_0.2.0    
[19] DBI_0.6-1        rgeos_0.3-22     assertthat_0.1   lazyeval_0.2.0   httpcode_0.2.0   tibble_1.3.3     ggplot2_2.2.1    triebeard_0.3.0  curl_2.6        
[28] crul_0.3.8       pracma_1.9.9     oai_0.2.2        stringi_1.1.3    urltools_1.6.0   scales_0.4.1    

Hi, thanks again for this package, which I'm using a lot.

I'm just trying to get country occurrence data for all plants on the Red List, but I keep hitting a Bad Gateway (HTTP 502) error. See below for the code I'm using. I already have a vector with all plant taxonid's (plant.id) and I'm trying lapply on a function rl.countries that should get the country occurrence for each taxonid. I usually get part of the way through before I get the 502 error.

I've been in touch with the Red List admin team and they say everything fine with the API, so I'm just trying to work out where the problem is.

Many thanks,
Steve Bachman

#get countries occurrence list based on taxon ID
rl.countries = function(x){
  cntry = rl_occ_country(id=x,key=rlkey)
  result = cntry$result
  taxonid = cntry$name
  results = cbind(name,result)
  colnames(results)[1] = 'taxonid'
  return(results)
}

#run lapply on rl.countries function
#plants.id is vector of taxonid's for all plants (total = 24,408) 
apply.countries = lapply(plants.id,rl.countries)
countries_df = as.data.frame(do.call(rbind,apply.countries))

Error: Bad Gateway (HTTP 502)

r1_comp_groups download for 'birds' does not work

I have been having some issues when trying to download the comprehensive list of species in the 'birds' group. The code I am using works for mammals, but for some reason, I am unable to do this for birds. 

This is the code that I am using in R:

all_mammals <-rl_comp_groups(group = c('mammals'), key = token) # token is my IUCN key. This code works and returns a list of all species in the group 'mammal'.
all_birds <-rl_comp_groups(group = c('birds'), key = token) # This does not work.

Is this an issue with the API? I have checked that the group name is correct. Any help would be appreciated.

changes from iucn

Problem to retrieve data of synonym

The function "rl_search" do not retrieve data of synonym, but in the website is possible search the data. There is information about it in the API too (http://apiv3.iucnredlist.org/api/v3/docs#species-synonym). How can I handling it?

#Example: Synonym of _Loxodonta africana_ do not retrieve data
rl_search("Loxodonta cyclotis", key = IUCN_REDLIST_KEY)
sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 15063)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rredlist_0.4.0

loaded via a namespace (and not attached):
[1] compiler_3.4.1  R6_2.2.2        curl_2.8.1      Rcpp_0.12.12   
[5] urltools_1.6.0  triebeard_0.3.0 crul_0.3.8      jsonlite_1.5   

Issue with downloading updated IUCN data (2023-1)

Hello,
The rl_sp(all = TRUE) function returns the previous version’s data (153,732 species). But the total assessed IUCN species count in the recent update (2023-1; December 11 2023 release) appears to be 157,190 (according to rl_sp_count).

I am in need of habitat and threat data for the 2023-1 version, but without the IUCN species names, I could not use the rl_habitats function to retrieve the updated information.

Is there an alternative approach to access the updated 2023-1 version?

Thank you,
Gopal

change maintainer on cran

@willgearty when you get a chance, could you submit a new version to cran changing the maintainer to you? not urgent, but any correspondence from cran will go to me right now, so it'd be good to have it go to you instead. thanks!

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.