All Projects → ropensci → rinat

ropensci / rinat

Licence: other
A programmatic interface to iNaturalist

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to rinat

riem
✈️ ☀️ R package for accessing ASOS data via the Iowa Environment Mesonet ☁️ ✈️
Stars: ✭ 38 (+5.56%)
Mutual labels:  rstats, r-package
geoparser
⛔ ARCHIVED ⛔ R package for the Geoparser.io API
Stars: ✭ 38 (+5.56%)
Mutual labels:  rstats, r-package
nasapower
API Client for NASA POWER Global Meteorology, Surface Solar Energy and Climatology in R
Stars: ✭ 79 (+119.44%)
Mutual labels:  rstats, r-package
tiler
Generate geographic and non-geographic map tiles from R
Stars: ✭ 56 (+55.56%)
Mutual labels:  rstats, r-package
styles
Custom themes for base plots
Stars: ✭ 32 (-11.11%)
Mutual labels:  rstats, r-package
rfishbase
R interface to the fishbase.org database
Stars: ✭ 79 (+119.44%)
Mutual labels:  rstats, r-package
cusumcharter
Easier CUSUM control charts. Returns simple CUSUM statistics, CUSUMs with control limit calculations, and function to generate faceted CUSUM Control Charts
Stars: ✭ 17 (-52.78%)
Mutual labels:  rstats, r-package
mapr
Map species occurrence data
Stars: ✭ 34 (-5.56%)
Mutual labels:  r-package, spocc
antiword
R wrapper for antiword utility
Stars: ✭ 47 (+30.56%)
Mutual labels:  rstats, r-package
agent
Store sensitive data such as API tokens
Stars: ✭ 19 (-47.22%)
Mutual labels:  rstats, r-package
mikropml
User-Friendly R Package for Supervised Machine Learning Pipelines
Stars: ✭ 34 (-5.56%)
Mutual labels:  rstats, r-package
individual
R Package for individual based epidemiological models
Stars: ✭ 20 (-44.44%)
Mutual labels:  rstats, r-package
cablecuttr
An R wrapper for CanIStream.It API
Stars: ✭ 17 (-52.78%)
Mutual labels:  rstats, r-package
pbapply
Adding progress bar to '*apply' functions in R
Stars: ✭ 115 (+219.44%)
Mutual labels:  rstats, r-package
travis
⛔ ARCHIVED ⛔ Set Up 'Travis' for Testing and Deployment
Stars: ✭ 61 (+69.44%)
Mutual labels:  rstats, r-package
cranlogs
Download Logs from the RStudio CRAN Mirror
Stars: ✭ 70 (+94.44%)
Mutual labels:  rstats, r-package
Shinycssloaders
⌛ Add loading animations to a Shiny output while it's recalculating
Stars: ✭ 248 (+588.89%)
Mutual labels:  rstats, r-package
Polite
Be nice on the web
Stars: ✭ 253 (+602.78%)
Mutual labels:  rstats, r-package
heddlr
Bring a functional programming mindset to R Markdown document generation
Stars: ✭ 14 (-61.11%)
Mutual labels:  rstats, r-package
pkgreviewr
R package to facilitate rOpenSci package reviews.
Stars: ✭ 35 (-2.78%)
Mutual labels:  rstats, r-package

rinat: Access iNaturalist data with R

Edmund Hart, Stéphane Guillou

Build Status Build status codecov.io

R wrapper for iNaturalist APIs for accessing the observations. The detailed documentation of the API is available on the iNaturalist website and is part of our larger species occurrence searching packages SPOCC.

Installation

You can install the latest version available on CRAN with:

install.packages("rinat")

Alternatively, you can install the development version from Github with:

remotes::install_github("ropensci/rinat")

Usage

Get observations

Text search

You can search for observations by either common or scientific name. It will search the entire iNaturalist database, so the search below will return all entries that mention Monarch butterflies, not just Monarch observations.

library(rinat)
monarchs <- get_inat_obs(query = "Monarch Butterfly")
unique(monarchs$scientific_name)
## [1] "Danaus plexippus" "Danaina"

Note that get_inat_obs() will return 100 observations by default. This can be controlled with the maxresults argument.

Another use for a fuzzy search is searching for a habitat, e.g. searching for all observations that might happen in a vernal pool. We can then see all the taxon names found.

vp_obs <- get_inat_obs(query = "vernal pool")
# see the first few taxa
head(vp_obs$scientific_name)
## [1] "Micrathetis triplex"     "Sphaeropthalma unicolor"
## [3] "Lepidoptera"             "Lepidoptera"            
## [5] "Synchlora faseolaria"    "Lepidoptera"

Taxon search

To return only records of a specific species or taxonomic group, use the taxon_name argument. For example, to return observations of anything from the Nymphalidae family, and restricting the search to the year 2015:

nymphalidae <- get_inat_obs(taxon_name  = "Nymphalidae", year = 2015)
# how many unique taxa?
length(unique(nymphalidae$scientific_name))
## [1] 79

And to return only the Monarch butterfly observations that also mention the term “chrysalis”:

monarch_chrysalis <- get_inat_obs(taxon_name = "Danaus plexippus", query = "chrysalis")

Bounding box search

You can also search within a bounding box by giving a simple set of coordinates.

## Search by area
bounds <- c(38.44047, -125, 40.86652, -121.837)
deer <- get_inat_obs(query = "Mule Deer", bounds = bounds)
plot(deer$longitude, deer$latitude)

Other functions

More functions are available, notably to access:

  • observations in a project with get_inat_obs_project()
  • details of a single observation with get_inat_obs_id()
  • observations from a single user with get_inat_obs_user()
  • taxa statistics with get_inat_taxon_stats()
  • user statistics with get_inat_user_stats()

More detailed examples are included in the vignette:

vignette("rinat-intro", package = "rinat")

Mapping

Basic maps can be created as well to quickly visualize search results. Maps can either be plotted automatically with plot = TRUE (the default), or simply return a ggplot2 object with plot = FALSE. This works well with single species data, but more complicated plots are best made from scratch.

library(ggplot2)

## Map 100 spotted salamanders
a_mac <- get_inat_obs(taxon_name = "Ambystoma maculatum")
salamander_map <- inat_map(a_mac, plot = FALSE)

### Now we can modify the returned map
salamander_map + borders("state") + theme_bw()

inat_map() is useful for quickly mapping data obtained with rinat. Here is an example of customised map that does not make use of it. (Not the use of quality = "research" to restrict the search to the more reliable observations.)

## A more elaborate map of Colibri sp.
colibri <- get_inat_obs(taxon_name = "Colibri",
                        quality = "research",
                        maxresults = 500)
ggplot(data = colibri, aes(x = longitude,
                         y = latitude,
                         colour = scientific_name)) +
  geom_polygon(data = map_data("world"),
                   aes(x = long, y = lat, group = group),
                   fill = "grey95",
                   color = "gray40",
                   size = 0.1) +
  geom_point(size = 0.7, alpha = 0.5) +
  coord_fixed(xlim = range(colibri$longitude, na.rm = TRUE),
              ylim = range(colibri$latitude, na.rm = TRUE)) +
  theme_bw()


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].