Skip to content

R package to access data from the NatureCounts platform by Bird Studies Canada

Notifications You must be signed in to change notification settings

pmorrill/naturecounts

 
 

Repository files navigation

naturecounts

lifecycle

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

Installation

You can install this developmental version of naturecounts from GitHub with the remotes package:

install.packages("remotes")
remotes::install_github("BirdStudiesCanada/naturecounts")

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")
#>      collection nrecords
#> 1      ABATLAS1   123364
#> 2      ABATLAS2   201398
#> 3    ABBIRDRECS   357264
#> 4         BGRMM      476
#> 5    EBUTTERFLY    26192
#> 6          IMMP       43
#> 7       IMMP_A2       24
#> 8       IMMP_BW       19
#> 9          IMQC      761
#> 10         MEXU     3251
#> 11         MLMP      802
#> 12           MM     4343
#> 13 MONARCHWATCH   145665
#> 14         PMMM        5
#> 15  RCBIOTABASE    12598
#> 16      SAMPLE1     1000
#> 17      SAMPLE2     1000
#> 18         WMMM     8981

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

nc_count(show = "all") %>%
  head()
#>   collection nrecords
#> 1   ABATLAS1   123364
#> 2   ABATLAS2   201398
#> 3 ABBIRDRECS   357264
#> 4     ATOWLS      367
#> 5        BBS  5735895
#> 6  BBS50-CAN  3219534

Fetching data

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

moose <- nc_data_dl(species = 133990, username = "sample")
#> Using filters: species (133990); fields_set (BMDE2.00-min)
#> Collecting available records...
#>    collection nrecords
#> 1 RCBIOTABASE        2
#> 
#> Downloading records for each collection:
#>   RCBIOTABASE
#>     Records 1 to 2 / 2

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

moose <- nc_data_dl(species = 133990, sql_db = "moose", username = "sample")
#> Using filters: species (133990); fields_set (BMDE2.00-min)
#> Collecting available records...
#>    collection nrecords
#> 1 RCBIOTABASE        2
#> 
#> Database 'moose.nc' does not exist, creating it...
#> 
#> Downloading records for each collection:
#>   RCBIOTABASE
#>     Records 1 to 2 / 2

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")
moose <- nc_data_dl(species = 133990, username = "my_user_name")

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.

About

R package to access data from the NatureCounts platform by Bird Studies Canada

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 99.8%
  • CSS 0.2%