Allows users to retrieve weather forecasts from Environment Canada’s Datamart service in tabular format.
Currently supports retrieving the following forecasts:
FYI: This package is still in development and breaking changes may occur in the near future.
You can get a list of all the locations with forecasts available by
using the rfca_cityweather_locations()
function
all_locations <- rfca_cityweather_locations()
head(all_locations)
## site_name site_id province
## 1 Athabasca s0000001 AB
## 2 Clearwater s0000002 BC
## 3 Valemount s0000003 BC
## 4 Grand Forks s0000004 BC
## 5 McBride s0000005 BC
## 6 Merritt s0000006 BC
ontario_locations <- rfca_cityweather_locations(prov = "ON")
head(ontario_locations)
## site_name site_id province
## 1 Marathon s0000022 ON
## 2 Terrace Bay s0000023 ON
## 3 Attawapiskat s0000024 ON
## 4 Gogama s0000025 ON
## 5 Hawkesbury s0000069 ON
## 6 Alexandria s0000070 ON
A data frame containing short codes for all provinces can be accessed
using data(prov_state_codes)
data(prov_state_codes)
# Filter for only Canadian short codes
prov_short_codes <- prov_state_codes %>%
filter(country == "CA")
head(prov_short_codes)
## # A tibble: 6 x 3
## country prov_state_shortcode prov_state_name
## <chr> <chr> <chr>
## 1 CA AB Alberta
## 2 CA BC British Columbia
## 3 CA MB Manitoba
## 4 CA NB New Brunswick
## 5 CA NL Newfoundland
## 6 CA NS Nova Scotia
You can then pass the site_id
for the site you’re interested in to
rfca_cityweather_forecast()
to retrieve the forecast
my_forecast <- rfca_cityweather_forecast(site_id = "s0000318")
my_forecast
## site_name site_id Timestamp Temperature Temperature_Units
## 1 Halifax s0000318 2018-11-19 16:00:00 2 C
## 2 Halifax s0000318 2018-11-19 17:00:00 3 C
## 3 Halifax s0000318 2018-11-19 18:00:00 3 C
## 4 Halifax s0000318 2018-11-19 19:00:00 3 C
## 5 Halifax s0000318 2018-11-19 20:00:00 3 C
## 6 Halifax s0000318 2018-11-19 21:00:00 3 C
## 7 Halifax s0000318 2018-11-19 22:00:00 4 C
## 8 Halifax s0000318 2018-11-19 23:00:00 5 C
## 9 Halifax s0000318 2018-11-20 00:00:00 6 C
## 10 Halifax s0000318 2018-11-20 01:00:00 6 C
## 11 Halifax s0000318 2018-11-20 02:00:00 7 C
## 12 Halifax s0000318 2018-11-20 03:00:00 7 C
## 13 Halifax s0000318 2018-11-20 04:00:00 7 C
## 14 Halifax s0000318 2018-11-20 05:00:00 7 C
## 15 Halifax s0000318 2018-11-20 06:00:00 7 C
## 16 Halifax s0000318 2018-11-20 07:00:00 6 C
## 17 Halifax s0000318 2018-11-20 08:00:00 6 C
## 18 Halifax s0000318 2018-11-20 09:00:00 5 C
## 19 Halifax s0000318 2018-11-20 10:00:00 3 C
## 20 Halifax s0000318 2018-11-20 11:00:00 4 C
## 21 Halifax s0000318 2018-11-20 12:00:00 5 C
## 22 Halifax s0000318 2018-11-20 13:00:00 5 C
## 23 Halifax s0000318 2018-11-20 14:00:00 5 C
## 24 Halifax s0000318 2018-11-20 15:00:00 5 C
## Wind_Direction Wind_Speed Wind_Speed_Units Condition
## 1 VR 5 km/h Periods of light snow
## 2 VR 5 km/h Periods of light snow
## 3 VR 5 km/h Showers
## 4 S 20 km/h Showers
## 5 S 20 km/h Showers
## 6 S 20 km/h Showers
## 7 S 20 km/h Periods of rain
## 8 S 20 km/h Periods of rain
## 9 S 20 km/h Periods of rain
## 10 S 20 km/h Periods of rain
## 11 S 20 km/h Periods of rain
## 12 S 20 km/h Periods of rain
## 13 S 20 km/h Periods of rain
## 14 S 20 km/h Periods of rain
## 15 N 10 km/h Periods of rain
## 16 N 10 km/h Overcast
## 17 N 10 km/h Overcast
## 18 N 10 km/h Overcast
## 19 VR 5 km/h Chance of showers
## 20 VR 5 km/h Chance of showers
## 21 VR 5 km/h Chance of showers
## 22 VR 5 km/h Chance of showers
## 23 VR 5 km/h Chance of showers
## 24 VR 5 km/h Chance of showers
You can get a list of available forecast locations using
rfca_naefs_locations()
. By default this returns all available
locations
naefs_locations <- rfca_naefs_locations()
head(naefs_locations)
## City WMO_code Latitude Longitude Altitude Country Province_state
## 1 Argentia 47.30 -54.00 16 CA NL
## 2 Badger 48.97 -56.07 105 CA NL
## 3 Bonavista 48.67 -53.12 27 CA NL
## 4 Burgeo 47.62 -57.62 12 CA NL
## 5 Cape Race 46.65 -53.07 28 CA NL
## 6 Cartwright YRF 53.70 -57.03 14 CA NL
## File_path
## 1 ARGENTIA_NL_CA
## 2 BADGER_NL_CA
## 3 BONAVISTA_NL_CA
## 4 BURGEO_NL_CA
## 5 CAPE_RACE_NL_CA
## 6 CARTWRIGHT_NL_CA
You can also subset locations by country using a two letter short code
# Canadian locatiosn
can_naefs_locations <- rfca_naefs_locations(country = "CA")
head(can_naefs_locations)
## City WMO_code Latitude Longitude Altitude Country Province_state
## 1 Argentia 47.30 -54.00 16 CA NL
## 2 Badger 48.97 -56.07 105 CA NL
## 3 Bonavista 48.67 -53.12 27 CA NL
## 4 Burgeo 47.62 -57.62 12 CA NL
## 5 Cape Race 46.65 -53.07 28 CA NL
## 6 Cartwright YRF 53.70 -57.03 14 CA NL
## File_path
## 1 ARGENTIA_NL_CA
## 2 BADGER_NL_CA
## 3 BONAVISTA_NL_CA
## 4 BURGEO_NL_CA
## 5 CAPE_RACE_NL_CA
## 6 CARTWRIGHT_NL_CA
Or by province/state
ontario_naefs_locations <- rfca_naefs_locations(province_state = "ON")
head(ontario_naefs_locations)
## City WMO_code Latitude Longitude Altitude Country
## 1 Armstrong YYW 50.30 -89.03 351 CA
## 2 Atikokan YIB 48.75 -91.62 393 CA
## 3 Barrie 44.38 -79.78 295 CA
## 4 Big Trout Lake YTL 53.83 -89.87 224 CA
## 5 Britt 45.80 -80.53 190 CA
## 6 Caribou Island YCI 47.33 -85.83 187 CA
## Province_state File_path
## 1 ON ARMSTRONG_ON_CA
## 2 ON ATIKOKAN_ON_CA
## 3 ON BARRIE_ON_CA
## 4 ON BIG_TROUT_LAKE_ON_CA
## 5 ON BRITT_ON_CA
## 6 ON CARIBOU_ISLAND_ON_CA
The full list of country short codes is available using
data(country_codes)
data(country_codes)
head(country_codes)
## # A tibble: 6 x 2
## country country_shortcode
## <chr> <chr>
## 1 Canada CA
## 2 United States US
## 3 Mexico MX
## 4 Antigua and Barbuda AG
## 5 Bahamas BS
## 6 Barbados BB
and the full list of province/state short codes using
data(prov_state_codes)
data(prov_state_codes)
head(prov_state_codes)
## # A tibble: 6 x 3
## country prov_state_shortcode prov_state_name
## <chr> <chr> <chr>
## 1 CA AB Alberta
## 2 MX AG Aguascalientes
## 3 US AK Alaska
## 4 US AL Alabama
## 5 US AR Arkansas
## 6 US AZ Arizona
The NAEFS forecast includes a variety of parameters. You can get a data
frame containing the short code for each parameter, as well as text
description and the units using rfca_naefs_parameters()
all_params <- rfca_naefs_parameters()
head(all_params)
## parameter
## 1 APCP-SFC
## 2 MSLP
## 3 TCDC
## 4 HGT-500HPA
## 5 LAYER-1000-500HPA
## 6 WIND-SFC
## parameter_desc
## 1 Surface Accumulated Precipitation
## 2 Mean Sea level Pressure
## 3 Total Cloud Cover
## 4 Geopotential at 500 hPa
## 5 Thicknesses (Geopotentiel Difference) between 1000 and 500 hPa
## 6 Surface Wind Speed
## parameter_desc_fr units
## 1 Précipitations accumulées à la surface mm
## 2 Pression moyenne au niveau de la mer hPa
## 3 Couvert nuageux total tenths
## 4 Géopotentiel à 500 hPa dam
## 5 Épaisseurs (différence de géopotentiel entre 1000 et 500 hPa dam
## 6 Vitesse du vent à la surface km/h
You can retrieve NAEFS forecasts for a specific location using
rfca_naefs_forecast()
which takes four arguments:
Sys.Date()
) but
Environment Canada archives forecasts for 30 days so you can query
older forecasts if you’d like.rfca_naefs_locations()
for valid optionsrfca_naefs_parameters()
for valid options.# Retrieve NAEFS forecast for Argentia, NL for current date
# (all parameters)
arg_forecast <- rfca_naefs_forecast(
forecast_time = "00",
forecast_location = "Argentia"
)
head(arg_forecast)
## Timestamp Values forecast_parameter Units Model_Id
## 1 2018-11-19 06:00:00 0 APCP-SFC mm 1
## 2 2018-11-19 06:00:00 0 APCP-SFC mm 2
## 3 2018-11-19 06:00:00 0 APCP-SFC mm 3
## 4 2018-11-19 06:00:00 0 APCP-SFC mm 4
## 5 2018-11-19 06:00:00 0 APCP-SFC mm 5
## 6 2018-11-19 06:00:00 0 APCP-SFC mm 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.