Eduard Szöcs

Data in Environmental Science and Eco(toxico-)logy

IUCN Red List with R

From a question to [r-sig-eco] mailing list:

Just a small function to get the status of a species from the IUCN Red List API:

require(XML)
get_IUCN_status <- function(x) {
    spec <- tolower(x)
    spec <- gsub(" ", "-", spec)
    url <- paste("http://api.iucnredlist.org/go/", spec, sep = "")
    h <- htmlParse(url)
    status <- xpathSApply(h, "//div[@id =\"red_list_category_code\"]", xmlValue)
    return(status)
}
get_IUCN_status("Panthera uncia")
## [1] "EN"

Have also a look at Kay Cichinis extended version!

Written on December 1, 2012