Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nikdata/rclimacell

See the package website: https://nikdata.github.io/RClimacell
https://github.com/nikdata/rclimacell

climacell climacell-api cran cran-r r weather weather-api

Last synced: about 1 month ago
JSON representation

See the package website: https://nikdata.github.io/RClimacell

Awesome Lists containing this project

README

        

---
output: github_document
---

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

# RClimacell

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![GitHub commit](https://img.shields.io/github/last-commit/nikdata/RClimacell)](https://github.com/nikdata/RClimacell/commit/main)
[![R-CMD-check](https://github.com/nikdata/RClimacell/workflows/R-CMD-check/badge.svg)](https://github.com/nikdata/RClimacell/actions)
[![CRAN status](https://www.r-pkg.org/badges/version/RClimacell)](https://CRAN.R-project.org/package=RClimacell)

The {RClimacell} package is an **unofficial** R package that enables basic interaction with [Climacell's](https://www.climacell.co) API using the [Timeline Interface](https://docs.climacell.co/reference/timeline-overview). The functions within this package are tested against some of the [Core data layers](https://docs.climacell.co/reference/data-layers-core).

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](https://docs.climacell.co/reference/api-overview) page.

### Lubridate Issue

As of 24 Feb, there is a [known issue](https://github.com/tidyverse/lubridate/issues/928) 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):

```r
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:

``` r
install.packages('RClimacell')
```

You can install the development version from [GitHub](https://github.com/) with:

``` r
# 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
```{r temperature_example}
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
```{r wind_example}
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
```{r}
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)

```{r}
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

```{r}
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)
```

```{r}
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](https://nikdata.github.io/RClimacell/) for more information.