This function fetches occurrence data for specified target species, utilizing both the event and occurrence tables from GBIF. The fetched dataset undergoes the following processing steps:
Join: Combines the event, occurrence, and measurementorfacts datasheets from GBIF into a single cohesive dataset.
Filter: Retains only the observations for specified species using the
target_species
argument. The entered Chinese common name was linked to scientific name by bbs_translate.Zero Fill: Converts implicit missing values into explicit ones by filling in zeros for trips where the target species was not observed. Specifically, if a plot was visited during a particular year or trip but the target species was not observed, the species count will show a value of 0 for that row.
Examples
# For single species data fetch
bbs_fetch(target_species = "紅嘴黑鵯")
#> # A tibble: 42,203 × 16
#> year month day site locationID decimalLatitude decimalLongitude weather
#> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <dbl> <chr>
#> 1 2009 4 26 A02-01 A02-01_01 25.1 122. NA
#> 2 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 3 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 4 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 5 2009 4 26 A02-01 A02-01_01 25.1 122. NA
#> 6 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 7 2009 4 26 A02-01 A02-01_02 25.1 122. NA
#> 8 2009 3 10 A02-01 A02-01_02 25.1 122. NA
#> 9 2009 4 5 A02-01 A02-01_02 25.1 122. NA
#> 10 2009 4 26 A02-01 A02-01_02 25.1 122. NA
#> # ℹ 42,193 more rows
#> # ℹ 8 more variables: wind <chr>, habitat <chr>, scientificName <chr>,
#> # vernacularName <chr>, individualCount <dbl>, time_slot <chr>,
#> # distance <chr>, flock <chr>
# For multiple species data fetch
bbs_fetch(target_species = c("紅嘴黑鵯", "白耳畫眉"))
#> # A tibble: 79,941 × 16
#> year month day site locationID decimalLatitude decimalLongitude weather
#> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <dbl> <chr>
#> 1 2009 4 26 A02-01 A02-01_01 25.1 122. NA
#> 2 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 3 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 4 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 5 2009 4 26 A02-01 A02-01_01 25.1 122. NA
#> 6 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 7 2009 4 26 A02-01 A02-01_02 25.1 122. NA
#> 8 2009 3 10 A02-01 A02-01_02 25.1 122. NA
#> 9 2009 4 5 A02-01 A02-01_02 25.1 122. NA
#> 10 2009 4 26 A02-01 A02-01_02 25.1 122. NA
#> # ℹ 79,931 more rows
#> # ℹ 8 more variables: wind <chr>, habitat <chr>, scientificName <chr>,
#> # vernacularName <chr>, individualCount <dbl>, time_slot <chr>,
#> # distance <chr>, flock <chr>
# To return data for all species
bbs_fetch(target_species = "全部")
#> # A tibble: 373,786 × 16
#> year month day site locationID decimalLatitude decimalLongitude weather
#> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <dbl> <chr>
#> 1 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 2 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 3 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 4 2009 4 26 A02-01 A02-01_01 25.1 122. NA
#> 5 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 6 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 7 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 8 2009 4 5 A02-01 A02-01_01 25.1 122. NA
#> 9 2009 3 10 A02-01 A02-01_01 25.1 122. NA
#> 10 2009 4 26 A02-01 A02-01_01 25.1 122. NA
#> # ℹ 373,776 more rows
#> # ℹ 8 more variables: wind <chr>, habitat <chr>, scientificName <chr>,
#> # vernacularName <chr>, individualCount <dbl>, time_slot <chr>,
#> # distance <chr>, flock <chr>
# The function will return NULL if the target species is not found in the
# BBS species list
bbs_fetch(target_species = "隨機鳥")
#> ! The bird is not in the BBS species list
#> ! 查無鳥名
#> NULL