knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

RClimacell

Lifecycle: experimental License: MIT GitHub commit R-CMD-check CRAN status

The {RClimacell} package is an unofficial R package that enables basic interaction with Climacell's API using the Timeline Interface. The functions within this package are tested against some of the Core data layers.

Please note that using the functions within this package require a valid API key.

More information about the Climacell API can be found on their docs page.

Lubridate Issue

As of 24 Feb, there is a known issue with using the package {lubridate} and it seems to be affecting macOS users. The 'fix' has been to add the following line to the .Renviron file or the .Rprofile (I applied the code into the .Renviron file and it worked):

TZDIR="/Library/Frameworks/R.framework/Resources/share/zoneinfo/"

{lubridate} version 1.7.10 fixes this issue and is available on CRAN.

Installation

CRAN version can be installed as follows:

install.packages('RClimacell')

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("nikdata/RClimacell")

Usage

Not every variable in each of the functions will have a value. Missing values are denoted by NA and indicate that the API did not return a value for the specific date/time and function call.

Temperature

library(RClimacell)
climacell_temperature(api_key = Sys.getenv("CLIMACELL_API"),
                      lat = 41.878685,
                      long = -87.636011,
                      timestep = '1d',
                      start_time = lubridate::now(),
                      end_time = lubridate::now() + lubridate::days(3))

Wind

library(RClimacell)
climacell_wind(api_key = Sys.getenv("CLIMACELL_API"),
               lat = 41.878685,
               long = -87.636011,
               timestep = '1d',
               start_time = lubridate::now(),
               end_time = lubridate::now() + lubridate::days(3))

Precipitation

library(RClimacell)
df_precip <- climacell_precip(api_key = Sys.getenv("CLIMACELL_API"),
                 lat = 41.878685,
                 long = -87.636011,
                 timestep = '1h',
                 start_time = lubridate::now(),
                 end_time = lubridate::now() + lubridate::days(3))

dplyr::glimpse(df_precip)

Celestial (sunset time, sunrise time, and moon phase)

library(RClimacell)
df_celestial <- climacell_celestial(api_key = Sys.getenv("CLIMACELL_API"),
                 lat = 41.878685,
                 long = -87.636011,
                 timestep = '1d',
                 start_time = lubridate::now(),
                 end_time = lubridate::now() + lubridate::days(5))

dplyr::glimpse(df_celestial)

Climacell Core (all Core Layer data)

This function aims to retrieve all of the Core Layer data using the Timeline Interface. All of the data are retrieved in a single API call. Note that if the timestep is not '1d', then the moon phase, sunrise time, and sunset times will not be available

library(RClimacell)
df_core <- climacell_core(api_key = Sys.getenv("CLIMACELL_API"),
                 lat = 41.878685,
                 long = -87.636011,
                 timestep = '1m',
                 start_time = lubridate::now(),
                 end_time = lubridate::now() + lubridate::hours(3))

dplyr::glimpse(df_core)
library(RClimacell)
df_core2 <- climacell_core(api_key = Sys.getenv("CLIMACELL_API"),
                 lat = 41.878685,
                 long = -87.636011,
                 timestep = '1d',
                 start_time = lubridate::now(),
                 end_time = lubridate::now() + lubridate::days(5))

dplyr::glimpse(df_core2)

See the vignette for more information.



nikdata/RClimacell documentation built on March 26, 2021, 10:43 p.m.