-
Notifications
You must be signed in to change notification settings - Fork 29
/
README.Rmd
executable file
·168 lines (107 loc) · 7.03 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
---
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 <img src="https://github.com/ropensci/weathercan/raw/main/inst/assets/weathercan_logo.png" align = "right" width = 110/>
[![: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)
<!-- [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/weathercan)](https://cran.r-project.org/package=weathercan) [![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/weathercan)](https://CRAN.R-project.org/package=weathercan) -->
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.
[![ropensci_footer](http://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org)
```{r, include = FALSE}
# Reset options
options(old)
```