AtlasOfLivingAustralia / galah-R

Query living atlases from R
https://galah.ala.org.au
38 stars 3 forks source link

`galah_select` for other atlases #181

Open fontikar opened 1 year ago

fontikar commented 1 year ago

Hey folks, I’ve been loving my tinkering with GBIF with {galah}, its soooo good that you don’t have to learn different syntax just to get data out from a non-ALA altas. This is a super minor suggestion and happy to help with this if you need.

I created the following query and had assumed that group = options would be transferrable to different atlases, but then get the error:

galah_config(email = Sys.getenv("ALA_EMAIL"),
             username = Sys.getenv("GBIF_USER"),
             password = Sys.getenv("GBIF_PWD"),
             atlas = "Global")

african_ele_projfields <- galah_call() %>% 
  galah_identify("Loxodonta africana") %>% 
  galah_select(group = "basic", project_fields) %>% 
  atlas_occurrences()

Error in `all_of()`:
! Can't subset columns that don't exist.
✖ Columns `taxonConceptID`, `recordID`, and `dataResourceName` don't exist.
Run `rlang::last_error()` to see where the error occurred.

It makes sense that not all fields are consistent across atlases. Perhaps this needs to be reflected in the galah_select help file/error message and other documentation, or in the future, we can create the same group = options for other atlases but this might be tricky really fast!

mjwestgate commented 1 year ago

OK this is an interesting one. Basically, when galah_select() is called with a group argument, it is passed to preset_cols (here), which behaves differently depending on which group is chosen:

So an obvious action is to update galah_select() to give better results for different atlases when group is either media or event. This might require some care, as not every atlas appears to have an image service.

More important for this specific query is how to use galah_select() for GBIF. My reading of the GBIF API docs is that selecting columns isn't possible from GBIF, in which case we need to: