vignettes/articles/using_rspeciesLink.Rmd
using_rspeciesLink.Rmd
Installing and loading the package:
devtools::install_github("liibre/Rocc")
This package downloads information from the speciesLink API. It generates the desired url and uses functions from jsonlite
package to GET the url and save the output as a csv file. The speciesLink API is a courtesy of Sidnei de Souza from CRIA (Centro de Referência em Informação Ambiental) :)
See ?rspeciesLink
for all search options. Bellow function’s arguments.
args(rspeciesLink)
#> function (dir = "results/", filename = "output", save = TRUE,
#> basisOfRecord = NULL, species = NULL, collectionCode = NULL,
#> country = NULL, stateProvince = NULL, county = NULL, Coordinates = NULL,
#> CoordinatesQuality = NULL, Scope = NULL, Synonyms = "no synomyms",
#> Typus = FALSE, Images = NULL, RedList = FALSE, MaxRecords = NULL)
#> NULL
Search for records of Eugenia platyphylla and Chaetocalyx acutifolia in speciesLink API. Same as: http://api.splink.org.br/records/ScientificName/Eugenia%20platyphylla/Chaetocalyx%20acutifolia/scope/plants
sp1 <- "Eugenia platyphylla"
sp2 <- "Chaetocalyx acutifolia"
Setting scope "plants"
.
ex01 <- rspeciesLink(filename = "ex01",
species = c(sp1, sp2),
Scope = "plants")
#> Making request to speciesLink...
#> Writing results/ex01.csv on disk.
Checking search output.
Checking if required species are in the output.
# are required species in the output
## list species in the output
ex01.sp <- unique(ex01$data$scientificName)
## check if species are in the output - yes!
c(sp1, sp2) %in% ex01.sp
#> [1] FALSE FALSE
Checking colnames in data output.
names(ex01$data)
|| || || ||
Search for Rauvolfia selowii and Cantinoa althaeifolia. Now using collectioncode
and Images
arguments.
ex02 <- rspeciesLink(filename = "ex02",
collectionCode = "uec",
species = c("Rauvolfia sellowii",
"Cantinoa althaeifolia"),
Images = "Yes")
#> Making request to speciesLink...
#> Writing results/ex02.csv on disk.
Checking again if species are in the search.
# again species are in the output
c("Rauvolfia sellowii", "Cantinoa althaeifolia") %in% ex02$data$scientificName
#> [1] FALSE FALSE
Checking url used in the search.
ex02$url
#> NULL
# check output
head(ex02$data)
#> NULL
dim(ex02$data)
#> NULL
str(ex02$data)
#> NULL
Is data only from UEC collection?
# check fiel collectioncode
unique(ex02$data$collectionCode)
#> NULL
For species Tillandsia stricta.
ex03 <- rspeciesLink(filename = "ex03",
species = "Tillandsia stricta",
Coordinates = "Yes",
CoordinatesQuality = "Good")
#> Making request to speciesLink...
#> Writing results/ex03.csv on disk.
Checking if species is in the output.
"Tillandsia stricta"%in%ex03$data$scientificName
#> [1] FALSE
Checking url and output.
Now with another selection of coordinate quality.
# another selection of coordinates quality
ex03b <- rspeciesLink(filename = "ex03b",
species = "Tillandsia stricta")
#> Making request to speciesLink...
#> Writing results/ex03b.csv on disk.
#coordinatesQuality = "Bad")
Checking url and output.
This example searches for 100 herbarium plants collected in Mariana county (Minas Gerais state, Brazil) that are in the IUCN Red List.
ex04 <- rspeciesLink(filename = "ex04",
Scope = "plants",
basisOfRecord = "PreservedSpecimen",
county = "Mariana",
stateProvince = c("Minas Gerais", "MG"),
country = c("Brazil", "Brasil"),
RedList = TRUE,
MaxRecords = 100)
#> Making request to speciesLink...
#> Writing results/ex04.csv on disk.
dim(ex04$data)
#> NULL
Checks for synonyms on Flora do Brasil 2020, the official plant list for taxonomic nomenclature.
ex05 <- rspeciesLink(filename = "ex05",
species = "Tillandsia stricta",
Synonyms = "flora2020")
#> Making request to speciesLink...
#> Writing results/ex05.csv on disk.
There is a limit of nine species for requiring to check for synonyms. If the lenght of species name vector is > 9, function stops.
tensp <- c(
"Tillandsia stricta", "Rauvolfia sellowii", "Cantinoa althaeifolia",
"Eugenia platyphylla","Chaetocalyx acutifolia", "Asplenium serra",
"Asplenium truncorum", "Prepusa montana", "Ocotea catharinensis",
"Asplenium triquetrum"
)
Function stops if argument Synonyms
is used with more than nine species. If
ex05 <- rspeciesLink(filename = "ex05",
species = tensp,
Synonyms = "flora2020")
Returns error:
Function does not support synonym check of more than nine species
Listing files on list.
resu <- list.files("results", pattern = '.csv', full.names = TRUE)
All outputs are readable.
all.resu <- lapply(resu, read.csv)