query_xenocanto searches for metadata from
Xeno-Canto.
Arguments
- species
Character string with the scientific name of a species in the format: "Genus epithet". Required. Can be set globally for the current R session via the "suwo_species" option (e.g.
options(suwo_species = "Hypsiboas rufitelus")). Alternatively, a character string containing additional tags that follows the Xeno-Canto advanced query syntax can be provided. Tags are of the form 'tag:searchterm'. For instance,'type:"song"'will search for recordings where the sound type contains 'song'. Multiple tags can be provided (e.g.,'"cnt:"belize" type:"song"'). See examples down below and check Xeno-Canto's search help for a full description.- cores
Numeric vector of length 1. Controls whether parallel computing is applied by specifying the number of cores to be used. Default is 1 (i.e. no parallel computing). Can be set globally for the current R session via the "mc.cores" option (e.g.
options(mc.cores = 2)). Note that some repositories might not support parallel queries from the same IP address as it might be identified as denial-of-service cyberattack.- pb
Logical argument to control if progress bar is shown. Default is
TRUE. Can be set globally for the current R session via the "suwo_pb" option (options(suwo_pb = TRUE)).- verbose
Logical argument that determines if text is shown in console. Default is
TRUE. Can be set globally for the current R session via the "suwo_verbose" option (options(suwo_verbose = TRUE)).- all_data
Logical argument that determines if all data available from database is shown in the results of search. Default is
FALSE. Can be set globally for the current R session via the "suwo_all_data" option (options(suwo_all_data = TRUE)).- raw_data
Logical argument that determines if the raw data from the repository is returned (e.g. without any manipulation). Default is
FALSE. Can be set globally for the current R session via the "suwo_raw_data" option (options(suwo_raw_data = TRUE)). IfTRUEall_datais set toTRUEinternally. Useful for developers, or if users suspect that some data is mishandled during processing (i.e. date information is lost). Note that the metadata obtained whenraw_data = TRUEis not standardized, so most suwo functions for downstream steps will not work on them.- api_key
Character string refering to the key assigned by Xeno-Canto as authorization for searches. Get yours at https://xeno-canto.org/account. Required. Avoid setting your API key directly in the function call to prevent exposing it in your code. Instead, set it as an environment variable (e.g., in your .Renviron file using
Sys.setenv(xc_api_key = "your_key_here")) named 'xc_api_key', so it can be accessed securely usingSys.getenv("xc_api_key").
Value
The function returns a data frame with the metadata of the media
files matching the search criteria. If all_data = TRUE, all metadata
fields (columns) are returned. If raw_data = TRUE, the raw data as
obtained from the repository is returned (without any formatting).
Details
This function queries metadata for animal sound recordings in the open-access online repository Xeno-Canto. Xeno-Canto hosts sound recordings of birds, frogs, non-marine mammals and grasshoppers. Complex queries can be constructed using the Xeno-Canto advanced query syntax (see examples).
References
Planqué, Bob, & Willem-Pier Vellinga. 2008. Xeno-canto: a 21st-century way to appreciate Neotropical bird song. Neotrop. Birding 3: 17-23.
Author
Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)
Examples
if (interactive()){
# An API key is required. Get yours at https://xeno-canto.org/account.
# run this in the console but dont save it in script
Sys.setenv(xc_api_key = "YOUR_API_KEY_HERE")
# Simple search for a species
p_anth <- query_xenocanto(species = "Phaethornis anthophilus")
# Search for same species and add specify country
p_anth_cr <- query_xenocanto(
species = 'sp:"Phaethornis anthophilus" cnt:"Panama"',
raw_data = TRUE)
# Search for female songs of a species
femsong <- query_xenocanto(
species = 'sp:"Thryothorus ludovicianus" type:"song" type:"female"')
}
