source("R/rfca_cityweather_locations.R")
source("R/rfca_cityweather_forecast.R")
source("R/rfca_naefs_locations.R")
source("R/rfca_naefs_parameters.R")
source("R/rfca_naefs_forecast.R")
library(dplyr)

Overview

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.

CityPage Weather Forecasts

Get List of Available Locations

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)
ontario_locations <- rfca_cityweather_locations(prov = "ON")
head(ontario_locations)

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)

Get Forecast for Location

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

North American Ensemble Forecast System (NAEFS) Forecasts

Get Available Locations

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)

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)

Or by province/state

ontario_naefs_locations <- rfca_naefs_locations(province_state = "ON")
head(ontario_naefs_locations)

The full list of country short codes is available using data(country_codes)

data(country_codes)
head(country_codes)

and the full list of province/state short codes using data(prov_state_codes)

data(prov_state_codes)
head(prov_state_codes)

Get Available Parameters

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)

Get NAEFS Forecast for Location

You can retrieve NAEFS forecasts for a specific location using rfca_naefs_forecast() which takes four arguments:

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


rywhale/rforecastca documentation built on May 4, 2019, 7:38 a.m.