https://github.com/ropensci/weathercan
R package for downloading weather data from Environment and Climate Change Canada
https://github.com/ropensci/weathercan
environment-canada peer-reviewed r r-package rstats weather-data weather-downloader
Last synced: 5 months ago
JSON representation
R package for downloading weather data from Environment and Climate Change Canada
- Host: GitHub
- URL: https://github.com/ropensci/weathercan
- Owner: ropensci
- License: gpl-3.0
- Created: 2016-06-07T22:20:22.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2023-09-20T22:14:12.000Z (over 1 year ago)
- Last Synced: 2024-10-29T21:01:44.698Z (6 months ago)
- Topics: environment-canada, peer-reviewed, r, r-package, rstats, weather-data, weather-downloader
- Language: R
- Homepage: https://docs.ropensci.org/weathercan
- Size: 60.6 MB
- Stars: 102
- Watchers: 11
- Forks: 29
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- open-sustainable-technology - weathercan - This package makes it easier to search for and download multiple months/years of historical weather data from the Environment and Climate Change Canada (ECCC) website. (Atmosphere / Meteorological Observation and Forecast)
- jimsghstars - ropensci/weathercan - R package for downloading weather data from Environment and Climate Change Canada (R)
README
---
output: github_document
---```{r, echo=FALSE, message=FALSE, warning=FALSE}
library(weathercan)
library(dplyr)
library(tibble)
knitr::opts_chunk$set(cache = FALSE,
fig.path = "tools/readme/")
old <- options(width = 160)
```# weathercan
[](https://ropensci.r-universe.dev)
[](https://ropensci.r-universe.dev)
[](https://github.com/ropensci/weathercan/actions)
[](https://app.codecov.io/gh/ropensci/weathercan)[](https://github.com/ropensci/software-review/issues/160) [](https://zenodo.org/badge/latestdoi/60650396) [](https://doi.org/10.21105/joss.00571)
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](https://climate.weather.gc.ca/historical_data/search_historic_data_e.html).
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](https://docs.ropensci.org/weathercan/) (or see the [development docs](http://ropensci.github.io/weathercan/))
> Check out the Demo weathercan shiny dashboard ([html](https://steffilazerte.shinyapps.io/weathercan_shiny/); [source](https://github.com/steffilazerte/weathercan_shiny))
## Installation
You can install `weathercan` from the [rOpenSci r-Universe](https://ropensci.r-universe.dev/):
```{r, eval = FALSE}
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")`## General usage
To download data, you first need to know the `station_id` associated with the station you're interested in.
### Stations
`weathercan` includes the function `stations()` which returns a list of stations and their details (including `station_id`).
```{r}
head(stations())
glimpse(stations())
```You can look through this data frame directly, or you can use the `stations_search` function:
```{r}
stations_search("Kamloops", interval = "hour")
```Time frame must be one of "hour", "day", or "month".
You can also search by proximity:
```{r}
stations_search(coords = c(50.667492, -120.329049), dist = 20, interval = "hour")
```You can update this list of stations with
```{r}
stations_dl()
```And check when it was last updated with
```{r}
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.### Weather
Once you have your `station_id`(s) you can download weather data:
```{r, R.options = list(tibble.max_extra_cols = 0)}
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:
```{r, R.options = list(tibble.max_extra_cols = 0)}
kam_pg <- weather_dl(station_ids = c(48248, 51423), start = "2018-02-01", end = "2018-04-15")
```## Climate Normals
To access climate normals, you first need to know the `climate_id` associated with the station you're interested in.
```{r}
stations_search("Winnipeg", normals_years = "current")
```Then you can download the climate normals with the `normals_dl()` function.
```{r}
n <- normals_dl("5023222")
```See the [Getting Started](https://docs.ropensci.org/weathercan/articles/weathercan.html)
vignette for more details.## Citation
```{r, warning = FALSE}
citation("weathercan")
```## License
The data and the code in this repository are licensed under multiple licences. All code is licensed [GPL-3](https://www.gnu.org/licenses/gpl-3.0.en.html). All weather data is licensed under the ([Open Government License - Canada](http://open.canada.ca/en/open-government-licence-canada)).
## `weathercan` in the wild!
- Browse [`weathercan` use cases](https://ropensci.org/usecases/) on rOpenSci.org
- Checkout the [`weathercan` Shiny App](https://nickrongkp.shinyapps.io/WeatherCan/) by Nick Rong (@nickyrong) and Nathan Smith (@WraySmith)
- R package [`RavenR`](https://github.com/rchlumsk/RavenR/tree/master/R) has functions for converting
ECCC data downloaded by `weathercan` to the .rvt format for Raven.
- R package [`meteoland`](https://github.com/emf-creaf/meteoland) has functions for converting ECCC
data downloaded by `weathercan` to the format required for use in `meteoland`.## Similar packages
**[`rclimateca`](https://github.com/paleolimbot/rclimateca)**
`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`](https://cran.r-project.org/package=mudata2) package by the same author.
**[`CHCN`](https://cran.r-project.org/package=CHCN)**
`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](https://quickcode.io/) and so is currently broken.
## Contributions
We welcome any and all contributions! To make the process as painless as possible for all involved, please see our [guide to contributing](CONTRIBUTING.md)
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By participating in this project you agree to abide by its terms.
[](https://ropensci.org)
```{r, include = FALSE}
# Reset options
options(old)
```