-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmo_download_iucn.Rmd
71 lines (48 loc) · 1.91 KB
/
mo_download_iucn.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
output: html_document
---
```{r global_options, include=FALSE}
knitr::opts_chunk$set(fig.width=12, fig.height=8, eval = FALSE,
echo=TRUE, warning=FALSE, message=FALSE,
tidy = TRUE, collapse = TRUE,
results = 'hold')
```
# Objective
After this short exercise you will be able to download conservation assessments for multiple species from the INternational Union for the Conservation of Nature (www.iucn.org)
# Input data needed
- a taxon name for which to obtain fossils
- a list of species or genera names
# Tasks
1. Download existing conservation assessments from www.iucn.org for your group of interest using the IUCN API.
2. Download the same data for a larger taxonomic group including your focus group (e.g. family or order).
3. Familiarize yourself with the data
# Tutorial
To obtain the the IUCN status of species using the r package [rredlist](https://cran.r-project.org/web/packages/rredlist/index.html), you need a token for the IUCN Redlist API.
```{r}
library(tidyverse)
library(readxl)
library(jsonlite)
library(rredlist)
iucn.key <- "YOUR TOKEN"
splist <- read_csv("example_data/day1_biodiversity_databases/bombacoideae_specieslist.csv") %>%
pull(species)
iucn <- data.frame()
#get conservation status from IUCN via the IUCN API
for(i in 1:length(splist)){
print(i)
pick <- jsonlite::fromJSON(rl_search_(splist[i], key = iucn.key))$result
# write.table(pick, "inst/secondary_woodyness_iucn_criteria.txt",
# append = T, col.names = F, row.names = F)
iucn <- bind_rows(iucn, pick)
Sys.sleep(1)
}
# check the data
head(iucn)
table(iucn$category)
# write to disk
write_csv(iucn, "output/bombacoideae_iucn_redlist_assessments.csv")
```
# Output generated
A .csv file with the conservation assessment for the species of your group of interest
# Further reading
https://cran.r-project.org/web/packages/rredlist/rredlist.pdf