Does anyone know how to use rinat (github.com/ropensci/rinat) to download occurence data using phenology as a query parameter? I’d like to download all observations of a taxon, but I only want flowering individuals. It appears that rinat does not provide a column for phenology in the output dataframe, and it does not have an obvious function for pulling observations of a specific phenology state.
I’ve created a project to aggregate all flowering individuals from the taxon, and I can download the ovservations using the export feature of iNaturalist. However, I’d like to make reproducable code (specifically in R), and I don’t want to have to duplicate projects for every taxon I want to investigate.
Any advice would be much appreciated.
i don’t really know anything about R or rinat, but it looks like the thing is built on top of the older iNat API (https://www.inaturalist.org/pages/api+reference), and as far as i can tell, it doesn’t look like there’s a way in the old API to reference annotations. so my guess would be that the only way to use rinat to pull in observations that are flowering only is to do what you did with a custom project.
are you actually using R to do additional number crunching, or are you just trying to pull down data? if you’re just trying to get data, there might be other ways to achieve that end.
I’m planning to do all downstream stuff in R (filtering, mapping, visualization, etc.), but I’m open to any methods of quickly retrieving occurrence data with phenology information included.
Yes, as @pisum noted, rinat only uses the older API which can’t do what you want. It appears that rinat hasn’t been updated in 2-1/2 years, so probably won’t be improved anytime soon. Depending on your R skills, you could in R construct a URL using the newer API (https://api.inaturalist.org/v1/docs/#!/Observations/get_observations) which returns a JSON object, then use R package jsonlite to parse it. Here’s a sample URL that retrieves only plants with plant_phenology=flowering:
(term_id=12 is “plant phenology”, and term_value_id=13 is “flowering”, documented under “Search for Annotations” here: https://forum.inaturalist.org/t/how-to-use-inaturalists-search-urls-wiki/63). If you’re trying to retrieve a lot of records, you’ll have to mess with the “per_page” and “page” parameters.
Hope this helps!
Awesome! Thanks, I’ll play around with that.
Check out my iNat profile for installation instructions and examples of a beta R package that can handle this request: https://www.inaturalist.org/people/hanly
Once installed, the following code will get you what you want (including combining all pages of JSON data) into a single data frame as long as the request doesn’t exceed 10,000 records:
df <- iNat(taxon_id = [insert the number here], quality_grade = "research", term_id= 12 , term_value_id = 13)
For example this would be Yellow Coneflower:
df <- iNat(taxon_id = 85332, quality_grade = "research", term_id= 12 , term_value_id = 13)
which recreates in a data frame the two flowering RG records seen here:
This gives you a data frame with 138 column variables that you can inspect with colnames(df) since likely you won’t need most of them.
Really cool! That’s exactly what I was looking for.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.