A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

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.
https://github.com/ropensci/weathercan

Category: Atmosphere
Sub Category: Meteorological Observation and Forecast

Keywords

environment-canada peer-reviewed r r-package rstats weather-data weather-downloader

Keywords from Contributors

ecology routing geocode archiving genome mocking cycle fish birds reproducibility

Last synced: about 13 hours ago
JSON representation

Repository metadata

R package for downloading weather data from Environment and Climate Change Canada

README.Rmd

          ---
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 

[![:name status badge](https://ropensci.r-universe.dev/badges/:name)](https://ropensci.r-universe.dev)
[![weathercan status badge](https://ropensci.r-universe.dev/badges/weathercan)](https://ropensci.r-universe.dev)
[![R-CMD-check](https://github.com/ropensci/weathercan/workflows/R-CMD-check/badge.svg)](https://github.com/ropensci/weathercan/actions)
[![codecov](https://codecov.io/gh/ropensci/weathercan/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ropensci/weathercan)

[![](https://badges.ropensci.org/160_status.svg)](https://github.com/ropensci/software-review/issues/160) [![DOI](https://zenodo.org/badge/60650396.svg)](https://zenodo.org/badge/latestdoi/60650396) [![DOI](http://joss.theoj.org/papers/10.21105/joss.00571/status.svg)](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. 

## 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.

## 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)

## Contributors






All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [all-contributors](https://allcontributors.org) specification. Contributions of any kind are welcome!

### Code


steffilazerte

boshek

JauntyJJS

maelle

nicholas512

mciechanumich

jeroen

RichardLitt

shandiya

kellijohnson-NOAA
### Issue Authors

paleolimbot

joethorley

pbulsink

durraniu

stefaniebutland

adamhsparks

nadrojordan

macsmith26

essicolo

sckott

AreliaTW

WatershedFlow

cgquick

emhodg

klwilson23

jjvenky

greenLauren

tspeidel

datacarvel

AmeerDotHydro

tspeidel-ey

Carina8899

amcilraithRRC

AnneDaySRK

a2grotto

FraserHemis

rajibshibly

mjdzr

juliasunga

KevCaz

ecwiebe

carlos-arnillas

gilberto-sassi

busmansholiday
### Issue Contributors

ebourlon

clairervh

rajeshroy402

urbaingeo4455

CamMakoJ

salix-d

wgieni
[![ropensci_footer](http://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org) ```{r, include = FALSE} # Reset options options(old) ```

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 5 days ago

Total Commits: 831
Total Committers: 17
Avg Commits per committer: 48.882
Development Distribution Score (DDS): 0.138

Commits in past year: 60
Committers in past year: 11
Avg Commits per committer in past year: 5.455
Development Distribution Score (DDS) in past year: 0.467

Name Email Commits
Stefanie LaZerte s****i@s****a 716
Sam Albers s****s@g****m 73
Russ Allen r****n@y****m 9
Jeremy Selva j****s@g****m 4
Maëlle Salmon m****n@y****e 4
Kevin Cazelles k****e@u****a 3
dependabot[bot] 4****] 3
nicholas512 n****2@g****m 3
Github Actions g****s@g****m 2
Jeroen Ooms j****s@g****m 2
Mark 1****h 2
Richard Littauer r****b@b****m 2
Shandiya Balasubramaniam s****b@g****m 2
mciechan m****n@m****u 2
Shandiya Balasubramaniam s****b@g****m 2
rOpenSci Bot m****t@g****m 1
kellijohnson-NOAA k****n@n****v 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 114
Total pull requests: 56
Average time to close issues: 4 months
Average time to close pull requests: 8 days
Total issue authors: 37
Total pull request authors: 14
Average comments per issue: 3.31
Average comments per pull request: 1.59
Merged pull request: 47
Bot issues: 0
Bot pull requests: 4

Past year issues: 13
Past year pull requests: 17
Past year average time to close issues: 17 days
Past year average time to close pull requests: about 16 hours
Past year issue authors: 3
Past year pull request authors: 10
Past year average comments per issue: 1.0
Past year average comments per pull request: 1.0
Past year merged pull request: 12
Past year bot issues: 0
Past year bot pull requests: 3

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/ropensci/weathercan

Top Issue Authors

  • steffilazerte (56)
  • boshek (14)
  • maelle (4)
  • macsmith26 (3)
  • AmeerDotHydro (2)
  • adamhsparks (2)
  • rajibshibly (2)
  • sckott (2)
  • WatershedFlow (1)
  • datacarvel (1)
  • AreliaTW (1)
  • durraniu (1)
  • emhodg (1)
  • FraserHemis (1)
  • joethorley (1)

Top Pull Request Authors

  • steffilazerte (24)
  • boshek (12)
  • dependabot[bot] (4)
  • maelle (3)
  • mciechanumich (2)
  • farhanreynaldo (2)
  • RichardLitt (2)
  • shandiya (1)
  • kellijohnson-NOAA (1)
  • mustberuss (1)
  • JauntyJJS (1)
  • kylehamilton (1)
  • nicholas512 (1)
  • KevCaz (1)

Top Issue Labels

  • feature (16)
  • help wanted (10)
  • good first issue (5)
  • ro-hackathon-2025 (3)
  • documentation (2)
  • bug (1)

Top Pull Request Labels

  • ro-hackathon-2025 (6)
  • dependencies (4)

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.3.0 depends
  • dplyr >= 1.0.0 imports
  • httr >= 1.4.2 imports
  • lubridate >= 1.7.1 imports
  • memoise >= 2.0.0 imports
  • methods >= 3.2.2 imports
  • purrr >= 0.3.4 imports
  • rappdirs >= 0.3.3 imports
  • readr >= 2.0.0 imports
  • rlang >= 0.1.4 imports
  • rvest >= 0.3.4 imports
  • stringi >= 1.1.2 imports
  • stringr >= 1.4.0 imports
  • tidyr >= 1.1.3 imports
  • tidyselect >= 1.0.0 imports
  • xml2 >= 0.1.2 imports
  • devtools * suggests
  • ggplot2 * suggests
  • htmltools * suggests
  • knitr * suggests
  • leaflet * suggests
  • lutz * suggests
  • mockery * suggests
  • naniar * suggests
  • rmarkdown * suggests
  • sf * suggests
  • sp * suggests
  • testthat * suggests
  • vcr >= 1.0.2 suggests
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite

Score: 7.661527081358518