Skip to contents

Downloads zip files (one per site) for available FLUXNET sites.

Usage

flux_download(
  file_list_df = NULL,
  site_ids = "all",
  download_dir = "fluxnet",
  overwrite = FALSE,
  ...
)

Arguments

file_list_df

When NULL (default), flux_listall() is used to determine the sites with data available to download (specific sites can be selected with site_ids). If file_list_df is supplied, it should be a data frame generated by flux_listall(), but potentially filtered to exlude some rows. This provides an alternative way of downloading only specific sites. See the examples for a possible use case. If file_list_df is not NULL, cache_dir, use_cache, and cache_age will be ingored but site_ids other than "all" will still be used.

site_ids

Character; either "all" to download all sites available, or a vector of site IDs. For example, c("UK-GaB", "CA-Ca2").

download_dir

The directory to download zip files to.

overwrite

Logical; overwrite already downloaded .zip files? If FALSE it will skip downloading existing files, unless they are invalid .zip files (e.g. due to partial download or corruption).

...

Arguments passed to flux_listall().

Value

Invisibly returns a tibble with the download URL, path on disk, HTTP status code, and whether or not the download was successful.

Examples

if (FALSE) { # \dontrun{
# Download data for all available sites
flux_download()

# Download data for just select site IDs
flux_download(site_ids = c("UK-GaB", "CA-Ca2"))

# Download specific sites filtered by site metadata (IGPB  and data hub for example)
available_sites <- flux_listall()
to_get <-
  available_sites[available_sites$igbp == "CRO" & available_sites$data_hub == "AmeriFlux", ]
flux_download(file_list_df = to_get)

# Get a fresh list of available data and overwrite any existing downloads
flux_download(use_cache = FALSE, overwrite = FALSE)
} # }