library(weathercan) library(dplyr) library(tibble) knitr::opts_chunk$set(cache = FALSE, fig.path = "tools/readme/") old <- options(width = 160)
This package makes it easier to search for and download multiple months/years of historical weather data from Environment and Climate Change Canada (ECCC) website.
Bear in mind that these downloads can be fairly large and performing multiple downloads may use up ECCC's bandwidth unnecessarily. Try to stick to what you need.
For more details and tutorials checkout the weathercan website (or see the development docs)
Check out the Demo weathercan shiny dashboard (html; source)
You can install weathercan
from the rOpenSci r-Universe:
install.packages("weathercan", repos = c("https://ropensci.r-universe.dev", "https://cloud.r-project.org"))
View the available vignettes with vignette(package = "weathercan")
View a particular vignette with, for example, vignette("weathercan", package = "weathercan")
To download data, you first need to know the station_id
associated with the station you're interested in.
weathercan
includes the function stations()
which returns a list of stations and their details (including station_id
).
head(stations()) glimpse(stations())
You can look through this data frame directly, or you can use the stations_search
function:
stations_search("Kamloops", interval = "hour")
Time frame must be one of "hour", "day", or "month".
You can also search by proximity:
stations_search(coords = c(50.667492, -120.329049), dist = 20, interval = "hour")
You can update this list of stations with
stations_dl()
And check when it was last updated with
stations_meta()
Note: For reproducibility, if you are using the stations list to gather your data, it can be a good idea to take note of the ECCC date of modification and include it in your reports/manuscripts.
Once you have your station_id
(s) you can download weather data:
kam <- weather_dl(station_ids = 51423, start = "2018-02-01", end = "2018-04-15") kam
You can also download data from multiple stations at once:
kam_pg <- weather_dl(station_ids = c(48248, 51423), start = "2018-02-01", end = "2018-04-15")
To access climate normals, you first need to know the climate_id
associated with the station you're interested in.
stations_search("Winnipeg", normals_years = "current")
Then you can download the climate normals with the normals_dl()
function.
n <- normals_dl("5023222")
See the Getting Started vignette for more details.
citation("weathercan")
The data and the code in this repository are licensed under multiple licences. All code is licensed GPL-3. All weather data is licensed under the (Open Government License - Canada).
weathercan
in the wild!weathercan
use cases on rOpenSci.orgweathercan
Shiny App by Nick Rong (@nickyrong) and Nathan Smith (@WraySmith)RavenR
has functions for converting
ECCC data downloaded by weathercan
to the .rvt format for Raven.meteoland
has functions for converting ECCC
data downloaded by weathercan
to the format required for use in meteoland
.weathercan
and rclimateca
were developed at roughly the same time and as a result, both present up-to-date methods for accessing and downloading data from ECCC. The largest differences between the two packages are: a) weathercan
includes functions for interpolating weather data and directly integrating it into other data sources. b) weathercan
actively seeks to apply tidy data principles in R and integrates well with the tidyverse including using tibbles and nested listcols. c) rclimateca
contains arguments for specifying short vs. long data formats. d) rclimateca
has the option of formatting data in the MUData format using the mudata2
package by the same author.
CHCN
is an older package last updated in 2012. Unfortunately, ECCC updated their services within the last couple of years which caused a great many of the previous web scrapers to fail. CHCN
relies on a decommissioned older web-scraper and so is currently broken.
We welcome any and all contributions! To make the process as painless as possible for all involved, please see our guide to contributing
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
# Reset options options(old)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.