Skip to contents

Set up WildTrax credentials

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')

Authenticate

Next, you use the wt_auth() function to authenticate.

# Authenticate
wt_auth()
#> Authentication into WildTrax successful.

The Auth0 token you obtained will last for 12 hours. After that time, you will need to re-authenticate.

Making API calls

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)
#>   organization_id organization                                 project
#> 1               5         ABMI    ABMI Adopt-a-Camera ARU Surveys 2017
#> 2               1           BU                             BATS & LATS
#> 3               5         ABMI Before-After Dose Response Project 2021
#> 4               5         ABMI Before-After Dose Response Project 2022
#> 5               1           BU             Big Grid Pilot Program 2014
#> 6               5         ABMI                               Big Grids
#>   project_id sensor tasks                      status
#> 1         42    ARU   309 Published - Map+Report Only
#> 2       1667    ARU 66224          Published - Public
#> 3        686    ARU  1873 Published - Map+Report Only
#> 4       1174    ARU  1014 Published - Map+Report Only
#> 5         32    ARU   733          Published - Public
#> 6        381    ARU  2226 Published - Map+Report Only

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 = 620, sensor_id = 'ARU', reports = "main", weather_cols = F) %>%
  tibble::as_tibble()
head(my_report)
#> # A tibble: 6 × 31
#>   organization project_id location  location_id location_buffer_m longitude
#>   <chr>             <dbl> <chr>           <dbl> <lgl>                 <dbl>
#> 1 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 2 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 3 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 4 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 5 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 6 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> # ℹ 25 more variables: latitude <dbl>, equipment_make <lgl>,
#> #   equipment_model <lgl>, recording_id <dbl>, recording_date_time <dttm>,
#> #   task_id <dbl>, aru_task_status <chr>, task_duration <dbl>,
#> #   task_method <chr>, species_code <chr>, species_common_name <chr>,
#> #   species_scientific_name <chr>, individual_order <dbl>, tag_id <dbl>,
#> #   individual_count <chr>, vocalization <chr>, detection_time <dbl>,
#> #   tag_duration <dbl>, rms_peak_dbfs <dbl>, tag_is_verified <lgl>, …

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
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()
spp_table |> arrange(species_code)
#> # A tibble: 4,443 × 6
#>    species_id species_code species_common_name       species_class species_order
#>         <dbl> <chr>        <chr>                     <chr>         <chr>        
#>  1       2780 10           Wolves, Coyotes and Alli… MAMMALIA      Carnivora    
#>  2       2705 100          Barren-ground Caribou     MAMMALIA      Artiodactyla 
#>  3       2738 105          Porcupine Caribou         MAMMALIA      Artiodactyla 
#>  4       2735 106          Peary Caribou             MAMMALIA      Artiodactyla 
#>  5       2750 107          Varying Lemming           MAMMALIA      Rodentia     
#>  6       2618 108          Bird                      AVES          NA           
#>  7       2616 109          Bear                      MAMMALIA      Carnivora    
#>  8       2694 110          Train                     NONE          NA           
#>  9       2728 114          Kermode Bear              MAMMALIA      Carnivora    
#> 10       2819 129          Opossum                   MAMMALIA      Didelphimorp…
#> # ℹ 4,433 more rows
#> # ℹ 1 more variable: species_scientific_name <chr>

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 ARU format
my_report
#> # A tibble: 388 × 31
#>    organization project_id location  location_id location_buffer_m longitude
#>    <chr>             <dbl> <chr>           <dbl> <lgl>                 <dbl>
#>  1 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  2 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  3 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  4 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  5 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  6 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  7 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  8 BU                  620 CHPP-WP-1       94515 NA                    -110.
#>  9 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 10 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> # ℹ 378 more rows
#> # ℹ 25 more variables: latitude <dbl>, equipment_make <lgl>,
#> #   equipment_model <lgl>, recording_id <dbl>, recording_date_time <dttm>,
#> #   task_id <dbl>, aru_task_status <chr>, task_duration <dbl>,
#> #   task_method <chr>, species_code <chr>, species_common_name <chr>,
#> #   species_scientific_name <chr>, individual_order <dbl>, tag_id <dbl>,
#> #   individual_count <chr>, vocalization <chr>, detection_time <dbl>, …
# As point count format
head(aru_as_pc)
#> # A tibble: 6 × 23
#>   organization project         project_id location location_id location_buffer_m
#>   <chr>        <chr>                <dbl> <chr>          <dbl> <lgl>            
#> 1 BU           General-Commun…        620 CHPP-WP…       94517 NA               
#> 2 BU           General-Commun…        620 CHPP-WP…       94518 NA               
#> 3 BU           General-Commun…        620 CHPP-WP…       89972 NA               
#> 4 BU           General-Commun…        620 CHPP-WP…       89972 NA               
#> 5 BU           General-Commun…        620 CHPP-WP…       89972 NA               
#> 6 BU           General-Commun…        620 CHPP-WP…       89972 NA               
#> # ℹ 17 more variables: latitude <dbl>, longitude <dbl>, survey_id <chr>,
#> #   survey_date <dttm>, survey_url <chr>, observer <chr>,
#> #   survey_distance_method <chr>, survey_duration_method <chr>,
#> #   detection_distance <chr>, detection_time <chr>, species_code <chr>,
#> #   species_common_name <chr>, species_scientific_name <chr>,
#> #   individual_count <chr>, detection_heard <lgl>, detection_seen <lgl>,
#> #   detection_comments <chr>