The download_data() function accesses and downloads atmospheric,
meteorological, and environmental data from various open-access data
sources.
Usage
download_data(
dataset_name = c("aqs", "ecoregion", "ecoregions", "geos", "goes", "goes_adp", "gmted",
"koppen", "koppengeiger", "merra2", "merra", "modis", "narr", "nlcd", "noaa",
"sedac_groads", "sedac_population", "groads", "population", "hms", "smoke", "tri",
"nei", "gridmet", "terraclimate", "huc", "cropscape", "cdl", "prism", "edgar",
"improve", "drought", "spei", "eddi", "usdm", "hrrr"),
directory_to_save = NULL,
acknowledgement = FALSE,
hash = FALSE,
nasa_earth_data_token = NULL,
rate_limit = 2,
...
)Arguments
- dataset_name
character(1). Dataset name or alias from the list below. Matching ignores case and accepts unambiguous partial matches. The default selects
"aqs".- directory_to_save
character(1). Directory to save / unzip (if zip files are downloaded) data.
- acknowledgement
logical(1). By setting
TRUEthe user acknowledges that the data downloaded using this function may be very large and use lots of machine storage and memory.- hash
logical(1). Return the source function's combined MD5 directory hash instead of its download summary. Default is
FALSE. The directory included in the hash depends on the source and can include existing files. Ignored whendownload = FALSEis passed through....- nasa_earth_data_token
character(1) or NULL. NASA EarthData authentication token. Required for NASA EarthData datasets:
"geos","merra2","modis","sedac_groads"/"groads", and"sedac_population"/"population". Can be a token string, a path to a file containing the token, orNULLto read from theNASA_EARTHDATA_TOKENenvironment variable. Ignored for datasets that do not use NASA EarthData authentication.- rate_limit
numeric(1). Non-negative request-throttling interval in seconds, passed to the source function. Default is 2. This controls the average request rate rather than a strict minimum gap between requests.
- ...
Source-specific selections and download controls, such as
date,year,timescale,version,download,show_progress,max_tries,unzip, andremove_zip. See the selected source function for its arguments.
Value
The selected downloader's return value, with its visibility preserved:
With
download = FALSE, an invisible preview list containingurls,destfiles, andn_files.With downloading enabled and
hash = FALSE, an invisible summary containingsuccess,failed,skipped,failed_urls, andfailed_files. The two failure vectors arecharacter(0)when no downloads failed, including when every file was skipped.With downloading enabled and
hash = TRUE, a visible character scalar containing the combined MD5 hash of the source's output directory.
Details
This wrapper selects a downloader and forwards arguments. The source function performs validation, directory setup, discovery, downloading, and extraction. Previews and directory layouts follow that function's behavior.
Sources using download_run() download files concurrently when the caller
has configured a fixed "default" mirai pool, and sequentially otherwise.
AQS currently downloads sequentially. Discovery and archive extraction run
in the calling process. See download_run() for daemon setup, worker
requirements, progress reporting, and rate scaling.
The "drought" alias calls download_drought() with its default SPEI source
unless source is supplied. The "spei", "eddi", and "usdm" aliases
call download_spei(), download_eddi(), and download_usdm() directly.
Supply the selected function's required arguments through .... The source
argument selects a drought source only when dataset_name = "drought".
See also
For details of each download function per dataset, Please refer to:
download_aqs:"aqs","AQS"download_ecoregion:"ecoregions","ecoregion"download_geos:"geos"download_goes:"goes","goes_adp","GOES"download_gmted:"gmted","GMTED"download_koppen_geiger:"koppen","koppengeiger"download_merra2: "merra2","merra","MERRA","MERRA2"download_narr:"narr"download_nlcd:"nlcd","NLCD"download_hms:"noaa","smoke","hms"download_groads:"sedac_groads","groads"download_population:"sedac_population","population"download_modis:"modis","MODIS"download_tri:"tri","TRI"download_nei:"nei","NEI"download_gridmet:"gridMET","gridmet"download_terraclimate:"TerraClimate","terraclimate"download_huc:"huc"download_cropscape:"cropscape","cdl"download_prism:"prism"download_edgar:"edgar"download_improve:"improve","IMPROVE"download_drought:"drought"download_spei:"spei"download_eddi:"eddi"download_usdm:"usdm"download_hrrr:"HRRR","hrrr"
Examples
if (FALSE) { # \dontrun{
download_data(
dataset_name = "narr",
variables = "weasd",
year = 2023,
directory_to_save = tempdir(),
acknowledgement = TRUE,
download = FALSE # Deprecated; may still contact the source.
)
} # }