download.met | R Documentation |
download.met()
attempts to download data from Environment Canada's
historical-data website, and to cache the files locally. Lacking a published
API, this function must rely on reverse-engineering of queries handled by
that web server. For that reason, it is brittle.
download.met(
id,
year,
month,
deltat,
type = "xml",
destdir = ".",
destfile,
force = FALSE,
quiet = FALSE,
debug = getOption("oceDebug")
)
id |
A number giving the "Station ID" of the station of interest. If not
provided, |
year |
A number giving the year of interest. Ignored unless |
month |
A number giving the month of interest. Ignored unless |
deltat |
Optional character string indicating the time step of the
desired dataset. This may be |
type |
String indicating which type of file to download, either
|
destdir |
Optional string indicating the directory in which to store
downloaded files. If not supplied, |
destfile |
Optional string indicating the name of the file. If not supplied, the file name is constructed from the other parameters of the function call, so subsequent calls with the same parameters will yield the same result, thus providing the key to the caching scheme. |
force |
Logical value indicating whether to force a download, even if the file already exists locally. |
quiet |
Logical value passed to |
debug |
an integer specifying whether debugging information is
to be printed during the processing. This is a general parameter that
is used by many |
If this function fails, users might try using Gavin Simpson's canadaHCD
package (reference 2). This package maintains a copy of the Environment
Canada listing of stations, and its find_station()
function provides an easy
way to determine Station IDs. After that, its hcd_hourly
function (and
related functions) make it easy to read data. These data can then be
converted to the met
class with as.met()
, although doing so leaves many
important metadata blank.
String indicating the full pathname to the downloaded file.
library(oce) # Download data for Halifax International Airport, in September # of 2003. This dataset is used for data(met) provided with oce. # Note that requests for data after 2012 month 10 yield all # missing values, for reasons unknown to the author. metFile <- download.met(6358, 2003, 9, destdir=".") met <- read.met(metFile)
Dan Kelley
Environment Canada website for Historical Climate Data
https://climate.weather.gc.ca/index_e.html
Gavin Simpson's canadaHCD
package on GitHub
https://github.com/gavinsimpson/canadaHCD
The work is done with utils::download.file()
.
Other functions that download files:
download.amsr()
,
download.coastline()
,
download.topo()
Other things related to met data:
[[,met-method
,
[[<-,met-method
,
as.met()
,
met
,
met-class
,
plot,met-method
,
read.met()
,
subset,met-method
,
summary,met-method
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.