class: title-slide, nologo ### Dr. Steffi LaZerte # `weathercan` ## An R package for accessing<br>Environment and Climate Change Canada weather data .align-bottom-left[<img src = "./Figures/twitter_black.jpg" style = "height: 40px; vertical-align:middle"> @steffilazerte <img src = "./Figures/github.png" style = "height: 40px; vertical-align:middle; margin-left: 25px"> steffilazerte <img src = "./Figures/web.png" style = "height: 40px; vertical-align:middle; margin-left: 25px"> steffilazerte.ca <img src = "./Figures/email.svg" style = "height: 25px; vertical-align:middle; margin-left: 25px"> sel@steffilazerte.ca] .align-bottom-right[July 2018] --- # A bit of background #### Dr. Steffi LaZerte <img src = "./Figures/bcch_singing_narrow.jpg", style = "width:400px; position: absolute; top: 50px; right: 150px;"> .spacer[] **Biologist (Animal Behaviour)** - BSc University of Toronto - MSc McGill University - PhD University of Northern BC .spacer[] -- **Working with R since 2007** - Analysis requires a lot of data prep! --- # A bit of background #### Dr. Steffi LaZerte .spacer[] **Independent biological consultant and R programmer** - Data cleaning, summarizing, and analysis - Custom R packages and scripts - R tutoring and workshops <img src = "./Figures/logo_eg.png", style = "width: 600px; position:absolute; bottom: 100px; right: 50%; -webkit-transform: translate(50%, 0);"> -- <div class = "redbox" style = "right: 100px; top: 250px">Solving data problems</div> --- # Historical weather data - Available from Environment and Climate Change Canada (ECCC) - 1840 to Present - Hourly, daily, monthly intervals - \> 8,000 stations (past and present) -- > **Lots of Data!** --- background-image: url("./Figures/ECCC_historical.png") background-size: 85% background-position: 50% 100% # Accessing data from ECCC website --- background-image: url("./Figures/ECCC_historical2.png") background-size: 90% background-position: 50% 50% --- background-image: url("./Figures/ECCC_historical3.png") background-size: 60% background-position: 50% 50% -- <!-- <div class = "arrow-left" style = "position:absolute; right: 370px; bottom: 300px;border: 5px solid red;width:100px; height:50px;border-radius: 10px;"></div> --> <div class = "highlightbox" style = "right: 23%; bottom: 36%; width: 200px; height: 90px;"></div> --- # Data good but not ready .center[<img src = "./Figures/ECCC_historical_data.png" style = "width:100%">] --- background-image: url("./Figures/weathercan_logo.png") background-size: 450px background-position: 50% 70% class: center, nologo # .red[`weathercan`]: An R package --- background-image: url("./Figures/R_sm.png") background-size: 200px background-position: 50% 80% class: center, nologo .spacer[ ] # .center.Rblue[What's R?] .spacer[ ] -- ### An open source, programming language, and software environment --- class: center, nologo .spacer[ ] # .center.Rblue[What's R?] .spacer[ ] ### An open source, programming language, and software environment Often used with RStudio IDE <img src = "./Figures/RStudio-Ball.png" style = "height:75px;vertical-align:middle;"> --- background-image: url("./Figures/Rexample.png") background-size: cover class: nologo --- # Why use `weathercan`? -- <div style = "height: 10px;"></div> #### Free - Free *and* open-source software (FOSS) -- #### Fast and Easy - One line of code to download data from many stations, over many years - Instantly usable -- #### Customizable - Data is trimmed to start and end times - You can specify stations, time intervals, timezones, etc. --- # Why use `weathercan`? .spacer[ ] .spacer[ ] #### **Reproducible!** > - Scripts provide a record of actions > - Make a note of the `weathercan` version (`packageVersion(weathercan)`) > - Hard to document mouse clicks or website searches --- # Getting started with .red[`weathercan`] .spacer[ ] #### Latest stable version (v0.2.7): ```r install.packages("weathercan") ``` .spacer[ ] #### Developmental version (v0.2.7.9000): ```r library(devtools) install_github("ropensci/weathercan", build_vignettes = TRUE) ``` --- # Basic usage #### Code ```r library(weathercan) w <- weather_dl(station_ids = c(50821, 51097), start = "2017-09-01", interval = "hour") ``` -- #### Output ``` ## # A tibble: 15,984 x 29 ## station_name station_id station_operator prov lat lon elev climate_id WMO_id TC_id ## * <chr> <dbl> <chr> <fct> <dbl> <dbl> <dbl> <chr> <chr> <chr> ## 1 BRANDON A 50821 NAV Canada MB 49.9 -100.0 409. 5010481 71140 YBR ## 2 BRANDON A 50821 NAV Canada MB 49.9 -100.0 409. 5010481 71140 YBR ## 3 BRANDON A 50821 NAV Canada MB 49.9 -100.0 409. 5010481 71140 YBR ## 4 BRANDON A 50821 NAV Canada MB 49.9 -100.0 409. 5010481 71140 YBR ## 5 BRANDON A 50821 NAV Canada MB 49.9 -100.0 409. 5010481 71140 YBR ## # ... with 1.598e+04 more rows, and 19 more variables ``` -- <div class = "redbox" style = "top: 27.25%; right: 17.5%; width: 150px; height: 0px;padding: 2px;"></div> <div style = "position: absolute; top: 18%; right: 18.5%;"><h5><strong>"day" or "month"<strong></h5></div> --- # Plotting ```r library(ggplot2) ggplot(data = w, aes(x = time, y = temp, colour = station_name)) + theme_bw() + geom_line() + scale_colour_viridis_d(end = 0.5) + labs(x = "Date", y = "Temperature C", colour = "Station") ``` <img src="LaZerte_AGCAN_2018_weathercan_files/figure-html/unnamed-chunk-5-1.png" width="100%" /> --- # And done! ```r library(weathercan) w <- weather_dl(station_ids = c(50821, 51097), start = "2017-09-01", interval = "hour") ggplot(data = w, aes(x = time, y = temp, colour = station_name)) + theme_bw() + geom_line() + scale_colour_viridis_d(end = 0.5) + labs(x = "Date", y = "Temperature C", colour = "Station") ``` --- # Hmmm... ```r library(weathercan) w <- weather_dl(station_ids = c(50821, 51097), start = "2017-09-01") ggplot(data = w, aes(x = time, y = temp, colour = station_name)) + theme_bw() + geom_line() + scale_colour_viridis_d(end = 0.5) + labs(x = "Date", y = "Temperature C", colour = "Station") ``` <div class = "highlightbox" style = "top: 23%; right: 55%; width: 170px; height: 30px;"></div> <div style = "position: absolute; top: 13%; right: 62%;"><h2><strong>?<strong></h3></div> -- .spacer[ ] > How do we get station ids? --- # Stations data set ```r stations ``` -- ``` ## # A tibble: 26,208 x 12 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> ## 1 AB ABEE AGDM 32232 3010010 71285 XAF 54.3 -113. 664 day 2002 2018 ## 2 AB ABEE AGDM 32232 3010010 71285 XAF 54.3 -113. 664 hour 1990 2018 ## 3 AB ABEE AGDM 32232 3010010 71285 XAF 54.3 -113. 664 month 2002 2007 ## 4 AB ACADIA VALLEY 2030 3020018 <NA> <NA> 51.2 -110. 732 day 1980 1991 ## 5 AB ACADIA VALLEY 47748 3020035 71048 PAC 51.1 -110. 735 day 2009 2018 ## 6 AB ACADIA VALLEY 2030 3020018 <NA> <NA> 51.2 -110. 732 hour NA NA ## 7 AB ACADIA VALLEY 47748 3020035 71048 PAC 51.1 -110. 735 hour 2009 2018 ## 8 AB ACADIA VALLEY 2030 3020018 <NA> <NA> 51.2 -110. 732 month 1980 1991 ## 9 AB ACADIA VALLEY 47748 3020035 71048 PAC 51.1 -110. 735 month NA NA ## 10 AB ACADIA VALLEY C… 2032 3020022 <NA> <NA> 51.1 -110. NA day 1965 1965 ## # ... with 2.62e+04 more rows ``` --- # Searching by station name ```r stations_search(name = "Brandon") ``` ``` ## # A tibble: 15 x 12 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> ## 1 MB BRANDON #1 WIN… 3474 5010498 <NA> <NA> 49.8 -100.0 396 day 1987 2002 ## 2 MB BRANDON #1 WIN… 3474 5010498 <NA> <NA> 49.8 -100.0 396 month 1987 2002 ## 3 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100.0 409. day 1941 2012 ## 4 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100.0 409. hour 1958 2012 ## 5 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100.0 409. month 1941 2012 ## 6 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. day 2012 2018 ## 7 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. hour 2012 2018 ## 8 MB BRANDON CDA 3472 5010485 <NA> <NA> 49.9 -100.0 363. day 1890 2010 ## 9 MB BRANDON CDA 3472 5010485 <NA> <NA> 49.9 -100.0 363. month 1890 2007 ## 10 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100.0 409. day 2012 2018 ## # ... with 5 more rows ``` -- <div class = "highlightbox" style = "width: 90px; height: 380px; right: 15.5%; top: 32.5%"></div> --- # Searching by station name ```r stations_search(name = "Brandon", interval = "hour") ``` -- ``` ## # A tibble: 3 x 12 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> ## 1 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100.0 409. hour 1958 2012 ## 2 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. hour 2012 2018 ## 3 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100.0 409. hour 2012 2018 ``` --- # Searching by station name (fancy) ```r stations_search(name = "Brandon|Winnipeg", interval = "hour") ``` -- ``` ## # A tibble: 8 x 12 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> ## 1 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100.0 409. hour 1958 2012 ## 2 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. hour 2012 2018 ## 3 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100.0 409. hour 2012 2018 ## 4 MB WINNIPEG A CS 27174 502S001 71849 XWG 49.9 -97.2 239. hour 2013 2018 ## 5 MB WINNIPEG INTL A 51097 5023227 <NA> YWG 49.9 -97.2 239. hour 2013 2018 ## 6 MB WINNIPEG RICHAR… 47407 5023226 71852 YWG 49.9 -97.2 239. hour 2008 2013 ## 7 MB WINNIPEG RICHAR… 3698 5023222 71852 YWG 49.9 -97.2 239. hour 1953 2013 ## 8 MB WINNIPEG THE FO… 28051 5023262 71579 XWN 49.9 -97.1 230 hour 1999 2018 ``` -- <div class = "highlightbox" style = "top: 46%; right: 65%; height: 35px; width: 280px;"></div> <div class = "highlightbox" style = "top: 59.75%; right: 65%; height: 35px; width: 280px;"></div> > Make a note: 50821 (Brandon) and 51097 (Winnipeg) --- # Alternative: Searching by coordinates - Search according to location: `c(latitude, longitude)` - Search within 10km of this location: `dist = 10` ```r stations_search(coords = c(49.84847, -99.95009), dist = 10, interval = "hour") ``` -- .narrow[ ``` ## # A tibble: 3 x 13 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end distance ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> <dbl> ## 1 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100.0 409. hour 2012 2018 5.73 ## 2 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100.0 409. hour 1958 2012 6.84 ## 3 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. hour 2012 2018 6.84 ``` ] -- <div class = "highlightbox" style = "top: 57%; right: 9.25%; height: 80px; width: 55px;"></div> --- # Alternative: Searching with `tidyverse` > Note here we're using the `stations` data frame directly ```r library(tidyverse) stations %>% filter(prov == "MB", start > 2000, interval == "day") ``` .narrow[ ``` ## # A tibble: 40 x 12 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> ## 1 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. day 2012 2018 ## 2 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100.0 409. day 2012 2018 ## 3 MB CFB SHILO CCOC 43343 5012673 <NA> <NA> 49.8 -99.6 372 day 2004 2005 ## 4 MB CHURCHILL 48969 5060595 71618 YYQ 58.7 -94.1 29.3 day 2010 2018 ## 5 MB CHURCHILL AWOS 47408 5060601 <NA> <NA> 58.7 -94.1 28.7 day 2008 2010 ## 6 MB CHURCHILL CLIM… 44244 5060608 71696 PYQ 58.7 -94.1 28.5 day 2005 2018 ## 7 MB CROSS LAKE JEN… 54658 5060622 71106 PJP 54.5 -98.0 219. day 2017 2018 ## 8 MB CYPRESS RIVER … 48128 5010641 71239 POY 49.6 -99.1 374 day 2009 2018 ## 9 MB DAUPHIN 48868 5040689 71036 YDN 51.1 -100. 304. day 2010 2018 ## 10 MB EMERSON AUTO 48068 5020881 71560 WEX 49 -97.2 242 day 2009 2018 ## # ... with 30 more rows ``` ] --- # Understanding the data #### Flags For each measurement there is a corresponding 'flag' column .compact[ ```r w_month <- weather_dl(station_id = 5401, start = "2017-01-01", interval = "month") names(w_month) # List all the column names ``` ``` ## [1] "station_name" "station_id" "station_operator" ## [4] "prov" "lat" "lon" ## [7] "elev" "climate_id" "WMO_id" ## [10] "TC_id" "date" "year" ## [13] "month" "dir_max_gust" "dir_max_gust_flag" ## [16] "extr_max_temp" "extr_max_temp_flag" "extr_min_temp" ## [19] "extr_min_temp_flag" "mean_max_temp" "mean_max_temp_flag" ## [22] "mean_min_temp" "mean_min_temp_flag" "mean_temp" ## [25] "mean_temp_flag" "snow_grnd_last_day" "snow_grnd_last_day_flag" ## [28] "spd_max_gust" "spd_max_gust_flag" "total_precip" ## [31] "total_precip_flag" "total_rain" "total_rain_flag" ## [34] "total_snow" "total_snow_flag" ``` ] -- <div class = "highlightbox" style = "bottom: 17.5%; left: 11%; height: 25px; width: 230px;"></div> <div class = "highlightbox" style = "bottom: 21.5%; right: 23.5%; height: 25px; width: 230px;"></div> --- # Understanding the data #### Flags .compact[ ```r select(w_month, date, mean_temp, mean_temp_flag) # Pull out some columns ``` ``` ## # A tibble: 14 x 3 ## date mean_temp mean_temp_flag ## * <date> <dbl> <chr> ## 1 2017-01-01 -4.4 "" ## 2 2017-02-01 -4.3 "" ## 3 2017-03-01 -5.2 "" ## 4 2017-04-01 7.9 "" ## 5 2017-05-01 11.8 E ## 6 2017-06-01 17.5 "" ## 7 2017-07-01 19.3 "" ## 8 2017-08-01 18.4 "" ## 9 2017-09-01 17 "" ## 10 2017-10-01 12.7 "" ## # ... with 4 more rows ``` ] -- <div class = "highlightbox" style = "bottom: 33%; left: 23.5%; height: 30px; width: 75px;"></div> --- background-image: url("./Figures/flags_vignette.png") background-position: 50% 90% background-size: 65% # Understanding the data #### Flags ```r vignette("flags", package = "weathercan") ``` --- # Understanding the data #### Units and measurements ``` ## # A tibble: 15,984 x 6 ## station_id time temp temp_dew rel_hum wind_dir ## * <dbl> <dttm> <dbl> <dbl> <dbl> <dbl> ## 1 50821 2017-09-01 00:00:00 20.8 17.3 80 18 ## 2 50821 2017-09-01 01:00:00 20.8 17.2 80 17 ## 3 50821 2017-09-01 02:00:00 20 16.9 83 17 ## 4 50821 2017-09-01 03:00:00 19.4 16.9 85 16 ## 5 50821 2017-09-01 04:00:00 19.2 17.2 88 19 ## 6 50821 2017-09-01 05:00:00 18.8 17.8 93 17 ## 7 50821 2017-09-01 06:00:00 18.9 17.9 94 16 ## 8 50821 2017-09-01 07:00:00 18.3 17.7 96 18 ## 9 50821 2017-09-01 08:00:00 19.9 17.8 88 20 ## 10 50821 2017-09-01 09:00:00 20.6 18.2 86 23 ## # ... with 1.597e+04 more rows ``` --- background-image: url("./Figures/glossary_vignette.png") background-position: 50% 95% background-size: 60% # Understanding the data #### Units and measurements ```r vignette("glossary", package = "weathercan") ``` --- # Combining with other data - Adding weather data to other data sets - Times don't always line up -- .pull-left[ #### Sediment data (for example) ``` ## # A tibble: 1,392 x 2 ## time amount ## <dttm> <dbl> ## 1 2017-09-01 00:05:34 168. ## 2 2017-09-01 00:35:34 157. ## 3 2017-09-01 01:05:34 176. ## 4 2017-09-01 01:35:34 185. ## 5 2017-09-01 02:05:34 163. ## 6 2017-09-01 02:35:34 169. ## 7 2017-09-01 03:05:34 168. ## # ... with 1,385 more rows ``` ] .pull-right[ #### Brandon weather data ``` ## # A tibble: 7,992 x 3 ## time temp pressure ## <dttm> <dbl> <dbl> ## 1 2017-09-01 00:00:00 20.8 96.2 ## 2 2017-09-01 01:00:00 20.8 96.2 ## 3 2017-09-01 02:00:00 20 96.1 ## 4 2017-09-01 03:00:00 19.4 96.1 ## 5 2017-09-01 04:00:00 19.2 96.1 ## 6 2017-09-01 05:00:00 18.8 96.0 ## 7 2017-09-01 06:00:00 18.9 96.0 ## # ... with 7,985 more rows ``` ] <div class = "highlightbox" style = "left: 18%; top: 55%; height:32%; width:8%"></div> <div class = "highlightbox" style = "right: 24.5%; top: 55%; height:32%; width:8%"></div> --- # Interpolating - Linear interpolation where possible - Only a single weather station at a time ```r w <- weather_dl(station_ids = 50821, start = "2017-09-01") ``` ```r sediment <- weather_interp(data = sediment, weather = w, col = c("temp", "pressure")) ``` ``` ## temp is missing 7 out of 7992 data, interpolation may be less accurate as a result. ``` ``` ## pressure is missing 7 out of 7992 data, interpolation may be less accurate as a result. ``` -- > Note messages regarding missing data. These are just a 'heads up', not errors --- # Interpolating .pull-left-55[ #### Sediment & weather data ``` ## # A tibble: 1,392 x 4 ## time amount temp pressure ## <dttm> <dbl> <dbl> <dbl> ## 1 2017-09-01 00:05:34 168. 20.8 96.2 ## 2 2017-09-01 00:35:34 157. 20.8 96.2 ## 3 2017-09-01 01:05:34 176. 20.7 96.1 ## 4 2017-09-01 01:35:34 185. 20.3 96.1 ## 5 2017-09-01 02:05:34 163. 19.9 96.1 ## 6 2017-09-01 02:35:34 169. 19.6 96.1 ## 7 2017-09-01 03:05:34 168. 19.4 96.1 ## # ... with 1,385 more rows ``` ] .pull-right-45[ #### Original weather data ``` ## # A tibble: 7,992 x 3 ## time temp pressure ## * <dttm> <dbl> <dbl> ## 1 2017-09-01 00:00:00 20.8 96.2 ## 2 2017-09-01 01:00:00 20.8 96.2 ## 3 2017-09-01 02:00:00 20 96.1 ## 4 2017-09-01 03:00:00 19.4 96.1 ## 5 2017-09-01 04:00:00 19.2 96.1 ## 6 2017-09-01 05:00:00 18.8 96.0 ## 7 2017-09-01 06:00:00 18.9 96.0 ## # ... with 7,985 more rows ``` ] <div class = "highlightbox" style = "left: 33%; top: 40.5%; height:32%; width:5%"></div> <div class = "highlightbox" style = "right: 14.25%; top: 40.5%; height:32%; width:5%"></div> --- background-image: url("./Figures/weathercan_logo.png") background-size: 450px background-position: 50% 70% class: center, nologo # Taking .red[`weathercan`] to the next level... --- # Getting the most out of `weathercan` #### 1. Download from multiple stations (spatial) .compact[ ```r mb <- filter(stations, prov == "MB", start <= "2018", end >= "2018", interval == "hour") mb ``` ``` ## # A tibble: 60 x 12 ## prov station_name station_id climate_id WMO_id TC_id lat lon elev interval start end ## <fct> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl> <dbl> <chr> <int> <int> ## 1 MB BERENS RIVER A 53321 5030201 <NA> YBV 52.4 -97.0 222. hour 2015 2018 ## 2 MB BERENS RIVER A 53318 5030204 <NA> YBV 52.4 -97.0 222. hour 2015 2018 ## 3 MB BERENS RIVER CS 3721 5030203 71158 WCF 52.4 -97.0 222. hour 1985 2018 ## 4 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100.0 409. hour 2012 2018 ## 5 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100.0 409. hour 2012 2018 ## 6 MB CARBERRY CS 27741 5010547 71170 WZE 49.9 -99.4 384. hour 1994 2018 ## 7 MB CARMAN U OF M … 26857 502I001 71147 WNK 49.5 -98.0 268. hour 1995 2018 ## 8 MB CHURCHILL 48969 5060595 71618 YYQ 58.7 -94.1 29.3 hour 2010 2018 ## 9 MB CHURCHILL A 50148 5060605 71618 YYQ 58.7 -94.1 29.3 hour 2012 2018 ## 10 MB CHURCHILL CLIM… 44244 5060608 71696 PYQ 58.7 -94.1 28.5 hour 2005 2018 ## # ... with 50 more rows ``` ] --- # Getting the most out of `weathercan` ```r manitoba <- weather_dl(station_ids = mb$station_id, start = "2018-07-01") ``` > Big data sets can take time to download: save the output for later ```r write_csv(manitoba, "./Data/manitoba_2018-07-01.csv") ``` --- # Getting the most out of `weathercan` .compact[ ```r ggplot(manitoba, aes(x = date, y = temp)) + stat_summary(geom = "ribbon", fun.y = median, fun.ymax = max, fun.ymin = min, alpha = 0.5) + stat_summary(geom = "line", fun.y = median) + labs(title = "July 2018 Min/Median/Max Temperatures in Manitoba, Canada", x = "Date", y = "Temperature C") ``` <img src="LaZerte_AGCAN_2018_weathercan_files/figure-html/unnamed-chunk-28-1.png" width="100%" /> ] --- # Getting the most out of `weathercan` <img src="LaZerte_AGCAN_2018_weathercan_files/figure-html/unnamed-chunk-29-1.png" width="100%" /> --- # Getting the most out of `weathercan` #### 2. Download from multiple years (temporal) - no '`start`' means download until the '`end`' date - no '`end`' means download from the '`start`' date to the present (or end of the data record) - no '`start`' OR '`end`' means download all data **Download ALL data:** ```r w <- weather_dl(station_ids = c(3472, 3698), interval = "month") write_csv(w, "./Data/brandon_winnipeg_historical.csv") ``` --- # Getting the most out of `weathercan` ```r ggplot(data = w, aes(x = mean_temp, fill = station_name)) + theme_bw() + geom_density(alpha = 0.5) + scale_fill_viridis_d(end = 0.5) + labs(title = "Distribution of Monthly Mean Temperatures", x = "Temperature C", y = "Density", fill = "Station") ``` <img src="LaZerte_AGCAN_2018_weathercan_files/figure-html/unnamed-chunk-31-1.png" width="100%" /> --- # Recap! -- #### 1. Load `weathercan` package ```r library(weathercan) ``` -- #### 2. Find a station ```r stations_search("Brandon") ``` -- #### 3. Download weather ```r w <- weather_dl(station_ids = 50821, start = "2017-09-01") ``` -- #### 4. Add weather data to an existing data set ```r sediment <- weather_interp(data = sediment, weather = w, cols = "temp") ``` --- # Last, but not least #### 5. Cite `weathercan` ```r citation("weathercan") ``` ``` ## ## To cite 'weathercan' in publications, please use: ## ## LaZerte, Stefanie E and Sam Albers (2018). weathercan: Download and format weather data ## from Environment and Climate Change Canada. The Journal of Open Source Software ## 3(22):571. doi:10.21105/joss.00571. ``` `weathercan` is - Part of the [ropensci project](https://ropensci.org/) - Published in [Journal of Open Source Software](https://joss.theoj.org/) Both involve rigorous review of code, best-practices and usability <img src = "./Figures/ropensci.svg", style = "width:150px; position:absolute; bottom: 150px; left: 650px"> <img src = "./Figures/joss.png", style = "width:150px; position:absolute; bottom: 80px; left: 650px"> --- # We invite contributions! .spacer[ ] #### Openly developed on GitHub <img src = "./Figures/github.png" style = "width: 35px; vertical-align: middle; margin-bottom: 5px;"> .spacer[ ] Contribute what you can (**You don't have to be an R programmer!**): - Ideas / Feature-requests - Bugs - Bug-fixes - Development .spacer[ ] <img src = "./Figures/github.png" style = "width: 35px; vertical-align: middle;">: <http://github.com/ropensci/weathercan> --- class: final-slide, nologo # Get help with .red[`weathercan`] **Tutorials and Reference:** <http://ropensci.github.io/weathercan> **This presentation:** <https://steffilazerte.github.io/Presentations/> .spacer[ ] **Contact Steffi:** <img src = "./Figures/twitter_black.jpg" style = "height: 40px; vertical-align:middle; margin-left: 10px"> @steffilazerte <img src = "./Figures/github.png" style = "height: 40px; vertical-align:middle; margin-left: 20px"> steffilazerte <img src = "./Figures/web.png" style = "height: 40px; vertical-align:middle; margin-left: 20px"> steffilazerte.ca <img src = "./Figures/email.svg" style = "height: 25px; vertical-align:middle; margin-left: 20px"> sel@steffilazerte.ca -- <div style = "position:absolute; bottom: 25%"> <h2>Thanks!</h2></div> <img src = "./Figures/logo_eg.png", style = "width: 400px; position:absolute; bottom: 19%; left: 40px"> .small[.align-bottom-left[Slides created with the R package [xaringan](https://github.com/yihui/xaringan), using [remark.js](https://remarkjs.com), [knitr](http://yihui.name/knitr), and [R Markdown](https://rmarkdown.rstudio.com)<br> <code class = "remark-inline-code">Compiled on 2018-07-31 with weathercan v0.2.7</code>]]