riNat
R wrapper for iNaturalist APIs for accessing the observations. The Detailed documentation of API is available on iNaturlaist website and is part of our larger species occurence searching packages SPOCC
Searching
Fuzzy search
You can search for observations by either common or latin name. It will search the entire iNaturalist entry, so the search below will return all entries that mention Monarch butterflies, not just entries for Monarchs.
butterflies <- get_inat_obs(query = "Monarch Butterfly")
Another use for a fuzzy search is searching for a common name or habitat, e.g. searching for all observations that might happen in a vernal pool. We can then see all the species names found.
vp_obs <- get_inat_obs(query = "vernal pool")
head(vp_obs$Species.guess)
## [1] "Eastern Hemlock (Tsuga canadensis)"
## [2] "Folded Downingia"
## [3] "Thysanocarpus curvipes"
## [4] "Turkey-tail"
## [5] "snail"
## [6] "Marbled salamander"
Taxon query To return only records for a specific species or taxonomic group, use the taxon option.
## Return just observations in the family Plecoptera
stone_flies <- get_inat_obs(taxon = "Plecoptera")
## Return just Monarch Butterfly records
just_butterflies <- get_inat_obs(taxon = "Danaus plexippus")
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)
Other functions
Get information and observations by project
You can get all the observations for a project if you know it's ID or name as an intaturalist slug
## Just get info about a project
vt_crows <- get_inat_obs_project("crows-in-vermont", type = "info", raw = FALSE)
## Loading required package: rjson
## 22 Records
## 0
## Now get all the observations for that project
vt_crows_obs <- get_inat_obs_project(vt_crows$id, type = "observations")
## 22 Records
## 0-100
Get observation details
Detailed information about a specific observation can be retrieved by observation ID. The easiest way to get the ID is from a more general search.
m_obs <- get_inat_obs(query = "Monarch Butterfly")
head(get_inat_obs_id(m_obs$Id[1]))
## $comments_count
## [1] 1
##
## $created_at
## [1] "2013-12-12T18:54:39-08:00"
##
## $delta
## [1] FALSE
##
## $description
## [1] "Oruga de Mariposa Monarca en 4to estadio."
##
## $geoprivacy
## NULL
##
## $iconic_taxon_id
## [1] 47158
Get all observations by user
If you just want all the observations by a user you can download all their observations by user ID. A word of warning though, this can be quite large (easily into the 1000's)
m_obs <- get_inat_obs(query = "Monarch Butterfly")
head(get_inat_obs_user(as.character(m_obs$User.login[1]), maxresults = 20))[,
1:5]
## Scientific.name Datetime
## 1 Danaus plexippus 2013-10-14 00:00:00 +0000
## 2 Danaus plexippus 2013-10-23 00:00:00 +0000
## 3 Danaus plexippus 2013-10-24 00:00:00 +0000
## 4 Danaus plexippus 2013-10-24 00:00:00 +0000
## 5 Battus philenor 2013-04-25 00:00:00 +0000
## 6 Epiphile adrasta 2013-02-15 00:00:00 +0000
## Description
## 1 Oruga de Mariposa Monarca en 4to estadio.
## 2 Oruga que apenas empezara su transformacion a Crisalida.
## 3 Una oruga se encontraba ya formando su crisalida.\n\n\n\n\n\n\nGracias a Armando Palomares por haber tomado tan excelente fotografia.
## 4 Esta Mariposa (Hembra) se encontraba a unos cuantos centimetros de su pupa de la cual habia salido, acerque mis manos y subio en ellas, duro aproximadamente de 2 a 3 min en mi mano, de la cual despues emprendio su vuelo.
## 5 Alimentandose.
## 6
## Place.guess Latitude
## 1 cd universitaria san nicolas 25.71
## 2 Ciudad Universitaria San Nicolas de los Garza 25.70
## 3 Ciudad Universitaria San Nicolas de los Garza 25.69
## 4 Ciudad Universitaria San Nicolas de los Garza 25.73
## 5 Parque Ninos Heroes San nicolas de los garza 25.72
## 6 Parque Natural la Estanzuela 25.54
Stats by taxa
Basic statistics are available for taxa counts by date, date range, place ID (numeric ID), or user ID (string)
## By date
counts <- get_inat_taxon_stats(date = "2010-06-14")
counts
## subspecies genus species variety
## 1 3 41 1
## By place_ID
vt_crows <- get_inat_obs_project("crows-in-vermont", type = "info", raw = FALSE)
## 22 Records
## 0
place_counts <- get_inat_taxon_stats(place = vt_crows$place_id)
place_counts
## phylum superfamily tribe superphylum class subfamily
## 10 12 2 1 17 12
## family epifamily genus order suborder subspecies
## 132 1 475 33 8 50
## subclass variety hybrid kingdom form fo
## 1 24 14 5 3 1
## species
## 2843
Stats by user
Similar statistics can be gotten for users. The same input parameters can be used, but results are the top five users by species count and observation count.
## By date
counts <- get_inat_user_stats(date = "2010-06-14")
counts
## $species
## count user.id user.login user.name
## 1 10 9706 greglasley Greg Lasley
## 2 4 10285 finatic BJ Stacey
## 3 3 382 tsoleau
## 4 3 873 tapbirds Scott Cox
## 5 3 3403 davidr David R
##
## $observations
## count user.id user.login user.name
## 1 10 9706 greglasley Greg Lasley
## 2 4 10285 finatic BJ Stacey
## 3 4 357 annetanne
## 4 3 382 tsoleau
## 5 3 3403 davidr David R
## By place_ID
vt_crows <- get_inat_obs_project("crows-in-vermont", type = "info", raw = FALSE)
## 22 Records
## 0
place_counts <- get_inat_user_stats(place = vt_crows$place_id)
place_counts
## $species
## count user.id user.login user.name
## 1 1182 12610 susanelliott
## 2 1021 11792 kylejones Kyle Jones
## 3 829 12045 larry522 Larry Clarfeld
## 4 816 317 catharus Kent McFarland
## 5 711 2179 charlie Charlie Hohn
##
## $observations
## count user.id user.login user.name
## 1 4983 2179 charlie Charlie Hohn
## 2 2387 12610 susanelliott
## 3 2203 317 catharus Kent McFarland
## 4 1978 11792 kylejones Kyle Jones
## 5 1370 3847 rpayne Ron Payne
Basic maps can be created as well to quickly visualize search results. Maps can either be plotted automatically plot = TRUE
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.
## Map salamanders in the genuse Ambystoma
m_obs <- get_inat_obs(taxon = "Ambystoma maculatum")
salamander_map <- inat_map(m_obs, plot = FALSE)
### Now we can modify the returned map
salamander_map + borders("state") + theme_bw()
## Warning: Removed 6 rows containing missing values (geom_point).