knitr::opts_chunk$set( collapse = TRUE, comment = '#>' )
# Attach package library(wildRtrax) library(tidyverse)
To obtain an Auth0 token, you must login into WildTrax using Auth0 (Google authorization is currently not supported). You also need to store your WildTrax user name and password as environment variables.
# Note that you need to use 'WT_USERNAME' and 'WT_PASSWORD' Sys.setenv(WT_USERNAME = 'guest', WT_PASSWORD = 'Apple123')
Next, you use the wt_auth()
function to authenticate.
# Authenticate wt_auth()
The Auth0 token you obtained will last for 12 hours. After that time, you will need to re-authenticate.
Once authenticated, you can now use various functions that call upon the WildTrax API. For instance, you can use wt_get_download_summary()
to see basic metadata about projects that you can download data for.
# Download the project summary you have access to my_projects <- wt_get_download_summary(sensor_id = 'ARU') head(my_projects)
Using the project_id number in the download summary you can then use wt_download_report()
to access the species data. You can also find the project_id number in the url of a WildTrax project, e.g. https://www.wildtrax.ca/home/aru-tasks.html?projectId=605&sensorId=ARU.
# Download the project report my_report <- wt_download_report(project_id = 605, sensor_id = 'ARU', reports = "main", weather_cols = F) %>% tibble::as_tibble()
# Download the project report my_report <- wt_download_report(project_id = 605, sensor_id = 'ARU', reports = "main", weather_cols = F) %>% tibble::as_tibble()
head(my_report)
An easy way to download multiple projects at once is to use wt_get_download_summary()
and then filter by a substring in order to get the project ids to download the data.
# Download all of the published Ecosystem Health ARU data to a single object eh_projects <- wt_get_download_summary(sensor_id = "ARU") %>% tibble::as_tibble() %>% dplyr::filter(grepl('^Ecosystem Health',project)) %>% dplyr::mutate(data = purrr::map(.x = project_id, .f = ~wt_download_report(project_id = .x, sensor_id = "ARU", weather_cols = F, reports = "main")))
Downloading the WildTrax species table with wt_get_species()
also grants you access to other valuable columns or provides a complete list of the species currently supported by WildTrax.
# Download the WildTrax species table spp_table <- wt_get_species()
# Download the WildTrax species table spp_table <- wt_get_species()
head(spp_table)
WildTrax also pre-formats ARU to point count (PC) data depending on the type of analysis you wish to perform. See the Boreal Avian Modelling project website and GitHub repositories to find out more on integration of avian point count and ARU data.
# As point count format aru_as_aru <- wt_download_report(project_id = 605 , sensor_id = 'ARU', reports = "main", weather_cols = F)
# As point count format aru_as_aru <- wt_download_report(project_id = 605, sensor_id = 'ARU', reports = "main", weather_cols = F)
# As point count format head(aru_as_aru)
# As ARU format aru_as_pc <- wt_download_report(project_id = 605, sensor_id = 'PC', reports = "main", weather_cols = F)
# As ARU format aru_as_pc <- wt_download_report(project_id = 605, sensor_id = 'PC', reports = "main", weather_cols = F)
# As point count format head(aru_as_pc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.