PoisotLab / GBIF.jl

Functions and types to access GBIF data from Julia
https://ecojulia.github.io/GBIF.jl/latest/
Other
19 stars 4 forks source link

The taxon function has no method to pass a taxon ID directly #17

Closed tpoisot closed 5 years ago

tpoisot commented 5 years ago

Currently, taxon performs only text search, but sometimes the ID of the taxon is known (for example, when we want the genus of a given species). This would require a second method.

The taxon function is defined here: https://github.com/EcoJulia/GBIF.jl/blob/master/src/taxon.jl

The GBIF API endpoint for taxa by ID is here: http://api.gbif.org/v1/species/216

MichielStock commented 5 years ago

@tpoisot Let's see if I can do this in half an hour!

tpoisot commented 5 years ago

:tada: make your PR on master, and @ me if you have questions!

MichielStock commented 5 years ago

I don't have much experience with querying a database:

This is how I understand it from the API, though the body which is collected always matches WELP....

Can you point me in the right direction?

tpoisot commented 5 years ago

@MichielStock the taxa informations are stored as a Pair: name => id, so maybe the function can have a method that accepts this. I would see two of them, in fact:

taxon(t::Pair) = taxon(t.second)
function taxon(id::Int)
 # general case with only the ID
end

And I think that in your example query, name should be idinstead.

MichielStock commented 5 years ago

OK, seems to work, though the result of such a query does not have the keys status, confidence and matchType, which are required by GBIFTaxon(o::Dict{String, Any}).

I can either

tpoisot commented 5 years ago

@MichielStock can you open a pull request? I'll have a look at what the changes were, and can give better advice on status, etc.

By the way, please also add your name to the .zenodo.json file at the root of the project.