hcd_download: Download CSV files of Historical Climate Data records

hcd_downloadR Documentation

Download CSV files of Historical Climate Data records

Description

Downloads raw CSV data files from the Canadian Historical Climate Data website. These are the raw files you would obtain if you accessed a data record through the HCD website.

Usage

hcd_download(
  station,
  file,
  dir = tempdir(),
  timescale = c("monthly", "daily", "hourly"),
  year = NULL,
  month = NULL,
  progress = TRUE
)

Arguments

station

character; one or more HCD station IDs.

file

character; one or more file names. If not supplied, file names of the form station-year-month.csv, with year and month appended as determined by argument timescale.

dir

character; vector of one or more directory paths in which CSV files will be saved.scale of the requested Historical Climate Data records. If multiple paths supplied, there should be one path per station.

timescale

character; the timescale of the requested Historical Climate Data records.

year

numeric; vector of one or more years. Needed for daily or hourly data only.

month

numeric; vector of one or months. Needed for hourly data only.

progress

logical; if TRUE, a bar is shown indicating progress in downloading station data from the HCD website.

Value

A character vector containing file paths to the downloaded CSVs is returned invisibly.

Author(s)

Gavin L. Simpson

Examples

f <- hcd_download(1707, timescale = "monthly")
file.exists(f)

## specifying multiple storage folders
dirs <- file.path(tempdir(), c("2855", "1707"))
dir.create(dirs[1])
dir.create(dirs[2])
f <- hcd_download(c(2855, 1707), timescale = "monthly", dir = dirs)
file.exists(f)
## ...and daily
f <- hcd_download(c(2855, 1707), timescale = "daily", dir = dirs,
                  year = 1999:2000)
file.exists(f)

gavinsimpson/canadaHCD documentation built on Sept. 23, 2023, 3:13 a.m.