Learn R Programming

⚠️There's a newer version (1.2.3) of this package.Take me there.

spocc

spocc = SPecies OCCurrence data

At rOpenSci, we have been writing R packages to interact with many sources of species occurrence data, including GBIF, Vertnet, BISON, iNaturalist, the Berkeley ecoengine, AntWeb, and eBird. Other databases are out there as well, which we can pull in. spocc is an R package to query and collect species occurrence data from many sources. The goal is to to create a seamless search experience across data sources, as well as creating unified outputs across data sources.

spocc currently interfaces with ten major biodiversity repositories

  1. Global Biodiversity Information Facility (GBIF) (via rgbif)

GBIF is a government funded open data repository with several partner organizations with the express goal of providing access to data on Earth's biodiversity. The data are made available by a network of member nodes, coordinating information from various participant organizations and government agencies.

  1. Berkeley Ecoengine (via ecoengine)

The ecoengine is an open API built by the Berkeley Initiative for Global Change Biology. The repository provides access to over 3 million specimens from various Berkeley natural history museums. These data span more than a century and provide access to georeferenced specimens, species checklists, photographs, vegetation surveys and resurveys and a variety of measurements from environmental sensors located at reserves across University of California's natural reserve system.

  1. iNaturalist

iNaturalist provides access to crowd sourced citizen science data on species observations.

  1. VertNet (via rvertnet)

Similar to rgbif, ecoengine, and rbison (see below), VertNet provides access to more than 80 million vertebrate records spanning a large number of institutions and museums primarly covering four major disciplines (mammology, herpetology, ornithology, and icthyology). Note that we don't currenlty support VertNet data in this package, but we should soon

  1. Biodiversity Information Serving Our Nation (via rbison)

Built by the US Geological Survey's core science analytic team, BISON is a portal that provides access to species occurrence data from several participating institutions.

  1. eBird (via rebird)

ebird is a database developed and maintained by the Cornell Lab of Ornithology and the National Audubon Society. It provides real-time access to checklist data, data on bird abundance and distribution, and communtiy reports from birders.

  1. AntWeb (via AntWeb)

AntWeb is the world's largest online database of images, specimen records, and natural history information on ants. It is community driven and open to contribution from anyone with specimen records, natural history comments, or images.

  1. iDigBio (via ridigbio)

iDigBio facilitates the digitization of biological and paleobiological specimens and their associated data, and houses specimen data, as well as providing their specimen data via RESTful web services.

  1. OBIS

OBIS (Ocean Biogeographic Information System) allows users to search marine species datasets from all of the world's oceans.

  1. Atlas of Living Australia

ALA (Atlas of Living Australia) contains information on all the known species in Australia aggregated from a wide range of data providers: museums, herbaria, community groups, government departments, individuals and universities; it contains more than 50 million occurrence records.

The inspiration for this comes from users requesting a more seamless experience across data sources, and from our work on a similar package for taxonomy data (taxize).

BEWARE: In cases where you request data from multiple providers, especially when including GBIF, there could be duplicate records since many providers' data eventually ends up with GBIF. See ?spocc_duplicates, after installation, for more.

Contributing

See CONTRIBUTING.md

Installation

Stable version from CRAN

install.packages("spocc", dependencies = TRUE)

Or the development version from GitHub

install.packages("devtools")
devtools::install_github("ropensci/spocc")
library("spocc")

Basic use

Get data from GBIF

(out <- occ(query = 'Accipiter striatus', from = 'gbif', limit = 100))
#> Searched: gbif
#> Occurrences - Found: 617,957, Returned: 100
#> Search type: Scientific
#>   gbif: Accipiter striatus (100)

Just gbif data

out$gbif
#> Species [Accipiter striatus (100)] 
#> First 10 rows of [Accipiter_striatus]
#> 
#> # A tibble: 100 × 63
#>                  name  longitude latitude  prov         issues        key
#>                 <chr>      <dbl>    <dbl> <chr>          <chr>      <int>
#> 1  Accipiter striatus  -97.12924 32.70085  gbif cdround,gass84 1453324136
#> 2  Accipiter striatus  -84.74625 40.01773  gbif cdround,gass84 1453369124
#> 3  Accipiter striatus  -72.58904 43.85320  gbif cdround,gass84 1453335509
#> 4  Accipiter striatus  -96.77096 33.22315  gbif cdround,gass84 1453335637
...

Pass options to each data source

Get fine-grained detail over each data source by passing on parameters to the packge rebird in this example.

(out <- occ(query = 'Setophaga caerulescens', from = 'ebird', ebirdopts = list(region = 'US')))
#> Searched: ebird
#> Occurrences - Found: 0, Returned: 199
#> Search type: Scientific
#>   ebird: Setophaga caerulescens (199)

Just ebird data

out$ebird
#> Species [Setophaga caerulescens (199)] 
#> First 10 rows of [Setophaga_caerulescens]
#> 
#> # A tibble: 199 × 12
#>                      name longitude latitude  prov
#>                     <chr>     <dbl>    <dbl> <chr>
#> 1  Setophaga caerulescens -81.74960 24.57340 ebird
#> 2  Setophaga caerulescens -82.50378 27.31897 ebird
#> 3  Setophaga caerulescens -82.81150 27.83556 ebird
#> 4  Setophaga caerulescens -93.94818 29.69841 ebird
...

Many data sources at once

Get data from many sources in a single call

ebirdopts = list(region = 'US'); gbifopts = list(country = 'US')
out <- occ(query = 'Setophaga caerulescens', from = c('gbif','bison','inat','ebird'), gbifopts = gbifopts, ebirdopts = ebirdopts, limit = 50)
dat <- occ2df(out)
head(dat); tail(dat)
#> # A tibble: 6 × 6
#>                     name   longitude  latitude  prov       date        key
#>                    <chr>       <chr>     <chr> <chr>     <date>      <chr>
#> 1 Setophaga caerulescens -122.673863 45.476817  gbif 2017-01-09 1453379582
#> 2 Setophaga caerulescens  -83.035698 35.431075  gbif 2016-04-25 1453190650
#> 3 Setophaga caerulescens  -83.162943 41.615537  gbif 2016-05-12 1269558094
#> 4 Setophaga caerulescens  -74.405661 40.058324  gbif 2016-05-20 1453340127
#> 5 Setophaga caerulescens  -83.449402 44.252577  gbif 2016-05-14 1291104360
#> 6 Setophaga caerulescens  -83.449517 44.253819  gbif 2016-05-07 1291149600
#> # A tibble: 6 × 6
#>                     name   longitude   latitude  prov       date      key
#>                    <chr>       <chr>      <chr> <chr>     <date>    <chr>
#> 1 Setophaga caerulescens -82.8282344 27.8851167 ebird 2017-04-18 L3547190
#> 2 Setophaga caerulescens   -82.64435  27.532639 ebird 2017-04-18  L189003
#> 3 Setophaga caerulescens -81.7713915 26.1084774 ebird 2017-04-18 L2603780
#> 4 Setophaga caerulescens -84.8486335  29.671734 ebird 2017-04-18  L352112
#> 5 Setophaga caerulescens -80.7833333 33.7833333 ebird 2017-04-18  L109521
#> 6 Setophaga caerulescens -81.9212021  26.746724 ebird 2017-04-17 L3579621

Clean data

All data cleaning functionality is in a new package scrubr. On CRAN.

Make maps

All mapping functionality is now in a separate package mapr (formerly known as spoccutils), to make spocc easier to maintain. On CRAN.

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for spocc in R doing citation(package = 'spocc')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Copy Link

Version

Install

install.packages('spocc')

Monthly Downloads

4,158

Version

0.8.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Scott Chamberlain

Last Published

July 5th, 2018

Functions in spocc (0.8.0)

as.bison

Coerce occurrence keys to bisonkey/occkey objects
occ_names

Search for species names across many data sources.
occ_coverage

Automatically generate coverages for a spocc search
spocc-package

Interface to many species occurrence data sources
as.ala

Coerce occurrence keys to ALA id objects
as.antweb

Coerce occurrence keys to antwebkey/occkey objects
spocc_capwords

Capitalize the first letter of a character string.
wkt_vis

Visualize well-known text area's on a map.
fixnames

Change names to be the same for each taxon.
occ2df

Combine results from occ calls to a single data.frame
inspect

Get more data on individual occurrences.
occ

Search for species occurrence data across many data sources.
as.idigbio

Coerce occurrence keys to idigbio objects
as.inat

Coerce occurrence keys to iNaturalist id objects
as.obis

Coerce occurrence keys to obis id objects
as.vertnet

Coerce occurrence keys to vertnetkey/occkey objects
occ_names_options

Look up options for parameters passed to each source for occ_names function
bbox2wkt

Convert a bounding box to a Well Known Text polygon, and a WKT to a bounding box
occ_options

Look up options for parameters passed to each source
as.gbif

Coerce occurrence keys to gbifkey/occkey objects
as.ecoengine

Coerce occurrence keys to ecoenginekey/occkey objects
spocc_duplicates

A note about duplicate occurrence records
spocc_objects

spocc objects and their print, plot, and summary methods