ropensci / taxize

A taxonomic toolbelt for R
https://docs.ropensci.org/taxize
Other
266 stars 59 forks source link

IUCN numeric ID #431

Closed davharris closed 8 years ago

davharris commented 9 years ago

Do any existing functions return IUCN's numeric IDs (e.g. 22679935 for the Canada Goose)? I'm finding that I need them for the birdlife_* functions in the traits package.

If there isn't currently a way to get them, what would the best option be? I could create a new function (either here or in the traits package), or if you'd prefer, maybe I could add it to an IUCN-related function here.

Thanks!

davharris commented 9 years ago

This code (based on iucn_summary) pulls out the numeric ID.

spec <- tolower(sciname)
spec <- gsub(" ", "-", spec)
url <- paste("http://api.iucnredlist.org/go/", spec, sep = "")
e <- try(h <- readLines(url), silent = silent)

id_plus = grep("http://www.iucnredlist.org/apps/redlist/details/", e, value = TRUE)
gsub(".*/", "", id_plus)
sckott commented 9 years ago

nice work answering your own question.

Do you thin it warrants a new fxn in taxize?

davharris commented 9 years ago

That's what I wasn't sure about. Whichever approach you prefer.

sckott commented 9 years ago

Sure, I think a iucn_id() function is warranted.

eduardszoecs commented 9 years ago

See also issue https://github.com/ropensci/taxize/issues/174.