knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

naturecounts

lifecycle R-CMD-check r-universe

Access and download data on plant and animal populations from various databases through NatureCounts, a service managed by Birds Canada.

See tutorials, documentation and articles on the naturecounts package Website

Installation

You can install the main version of naturecounts from our R-Universe

install.packages("naturecounts", 
                 repos = c(birdscanada = 'https://birdscanada.r-universe.dev',
                           CRAN = 'https://cloud.r-project.org'))

Usage

library(naturecounts)

Fetching counts

Use the nc_count() function to return collections and the number of observations in each for which you have access (here returns all collections associated with username sample).

nc_count(username = "sample")

Use the show = "all" argument to show counts for all collections available (public or otherwise).

nc_count(show = "all") %>%
  head()

Fetching data

Fetch all observations of bittern which are available to user sample into a local data frame.

First find the species id

search_species("American Bittern")

Use this id with nc_data_dl(). The info parameter is a short description of what the data is being downloaded for.

bittern <- nc_data_dl(species = 2490, username = "sample", 
                    info = "readme_example")

Alternatively, save the downloaded data as a SQLite database (bittern).

bittern <- nc_data_dl(species = 2490, sql_db = "bittern", username = "sample", 
                    info = "readme_example")
file.remove("bittern.nc")

Authorizations

To access private/semi-public projects/collections you must sign up for a free NatureCounts account and register for the projects you'd like to access. Once registered, you can use the username argument (you will be prompted for a password) for both nc_count() and nc_data_dl(), which will then return a different set of records.

nc_count(username = "my_user_name")
bittern <- nc_data_dl(species = 2490, username = "my_user_name", info = "readme_example")

More advanced options

nc_count() and nc_data_dl() have a variety of arguments that allow you to filter the counts/data prior to downloading. These options include collections, species, years, doy (day-of-year), region, and site_type (users can specify up to 3 of these). For nc_data_dl() you have the additional arguments fields_set and fields with which you can customize which fields/columns to include in your download.

See the function examples (nc_count(), nc_data_dl()) the following articles for more information on these filters:

We also have an article on post-filtering your data

Metadata

NatureCounts includes a great deal of metadata which can be accessed through the functions with the meta_ prefix. See the Meta Documentation for specifics.



BirdStudiesCanada/naturecounts documentation built on June 30, 2023, 1:59 a.m.