SkillAgentSearch skills...

Darksky

:cloud: R interface to the Dark Sky API [APPLE IS SHUTTING DOWN THE API 2022-12-31]

Install / Use

/learn @hrbrmstr/Darksky
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

NOTICE APPLE IS SHUTTING DOWN THE API 2021-12-31

Alt wx API I'm considering wrapping as an alternative — https://www.visualcrossing.com/resources/documentation/weather-api/how-to-replace-the-dark-sky-api/

<!-- [![Coverage Status](https://img.shields.io/codecov/c/github/hrbrmstr/darksky/master.svg)](https://codecov.io/github/hrbrmstr/darksky?branch=master) --> <!-- [![Build Status](https://travis-ci.org/hrbrmstr/darksky.svg?branch=master)](https://travis-ci.org/hrbrmstr/darksky) --> <!-- [![Build status](https://ci.appveyor.com/api/projects/status/gq0uxmae9ii64g6q?svg=true)](https://ci.appveyor.com/project/hrbrmstr/darksky) --> <!-- [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/darksky)](https://cran.r-project.org/package=darksky) --> <!-- ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/darksky) -->

darksky : Tools to Work with the Dark Sky API

The following functions are implemented:

  • darksky_api_key : Get or set DARKSKY_API_KEY value
  • get_current_forecast : Retrieve the current forecast (for the next week)
  • get_forecast_for : Retrieve weather data for a specific place/time
  • plot.darksky : Plot method for darksky objects
  • print.darksky : A tad more human readable default printing

Installation

devtools::install_github("hrbrmstr/darksky")

OR

devtools::install.packages("darksky")

Usage

library(darksky)
library(tidyverse)

# current verison
packageVersion("darksky")
## [1] '1.3.0'
now <- get_current_forecast(43.2672, -70.8617)
print(now)
## minutely 
## ======================================================================================================================== 
## 'data.frame':    61 obs. of  3 variables:
##  $ time             : POSIXct, format: "2018-05-29 15:54:00" "2018-05-29 15:55:00" "2018-05-29 15:56:00" "2018-05-29 15:57:00" ...
##  $ precipIntensity  : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ precipProbability: int  0 0 0 0 0 0 0 0 0 0 ...
## NULL
## 
## hourly 
## ======================================================================================================================== 
## 'data.frame':    49 obs. of  18 variables:
##  $ time               : POSIXct, format: "2018-05-29 15:00:00" "2018-05-29 16:00:00" "2018-05-29 17:00:00" "2018-05-29 18:00:00" ...
##  $ summary            : chr  "Clear" "Clear" "Clear" "Clear" ...
##  $ icon               : chr  "clear-day" "clear-day" "clear-day" "clear-day" ...
##  $ precipIntensity    : num  0 0 0.001 0.0018 0 0.0013 0.0012 0 0.0004 0 ...
##  $ precipProbability  : num  0 0 0.01 0.02 0 0.03 0.03 0 0.02 0 ...
##  $ temperature        : num  83.5 83.2 82.1 79.4 75.7 ...
##  $ apparentTemperature: num  83.5 83.2 82.1 79.4 75.7 ...
##  $ dewPoint           : num  55.9 56.8 57 58.5 60.4 ...
##  $ humidity           : num  0.39 0.41 0.42 0.49 0.59 0.72 0.79 0.79 0.75 0.75 ...
##  $ pressure           : num  1014 1014 1014 1015 1016 ...
##  $ windSpeed          : num  0.35 2.73 2.42 2.1 2.15 2.32 2.79 3.05 3.84 4.21 ...
##  $ windGust           : num  7.3 6.84 5.68 5.74 5.81 ...
##  $ windBearing        : int  140 136 132 121 131 150 82 65 53 55 ...
##  $ cloudCover         : num  0.03 0.01 0.03 0.03 0.04 0.04 0.07 0.1 0.12 0.15 ...
##  $ uvIndex            : int  5 3 2 1 0 0 0 0 0 0 ...
##  $ visibility         : num  8.96 7.3 10 10 10 10 10 10 10 10 ...
##  $ ozone              : num  343 343 343 342 342 ...
##  $ precipType         : chr  NA NA "rain" "rain" ...
## NULL
## 
## daily 
## ======================================================================================================================== 
## 'data.frame':    8 obs. of  39 variables:
##  $ time                       : POSIXct, format: "2018-05-29" "2018-05-30" "2018-05-31" "2018-06-01" ...
##  $ summary                    : chr  "Mostly cloudy in the morning." "Partly cloudy throughout the day." "Foggy overnight." "Foggy in the morning." ...
##  $ icon                       : chr  "partly-cloudy-day" "partly-cloudy-day" "fog" "fog" ...
##  $ sunriseTime                : POSIXct, format: "2018-05-29 05:09:10" "2018-05-30 05:08:36" "2018-05-31 05:08:03" "2018-06-01 05:07:33" ...
##  $ sunsetTime                 : POSIXct, format: "2018-05-29 20:15:37" "2018-05-30 20:16:28" "2018-05-31 20:17:18" "2018-06-01 20:18:07" ...
##  $ moonPhase                  : num  0.51 0.54 0.57 0.6 0.63 0.66 0.69 0.72
##  $ precipIntensity            : num  0.0003 0.0003 0.0004 0.0041 0.0067 0.0258 0.0006 0.0131
##  $ precipIntensityMax         : num  0.0018 0.0014 0.003 0.0101 0.0199 0.0608 0.0046 0.0285
##  $ precipIntensityMaxTime     : POSIXct, format: "2018-05-29 18:00:00" "2018-05-30 01:00:00" "2018-05-31 20:00:00" "2018-06-01 15:00:00" ...
##  $ precipProbability          : num  0.14 0.12 0.13 0.35 0.49 0.71 0.21 0.49
##  $ precipType                 : chr  "rain" "rain" "rain" "rain" ...
##  $ temperatureHigh            : num  83.5 69.5 72.6 75.4 66 ...
##  $ temperatureHighTime        : int  1527620400 1527703200 1527793200 1527886800 1527966000 1528056000 1528135200 1528214400
##  $ temperatureLow             : num  52.9 48.1 59.8 60.2 48.8 ...
##  $ temperatureLowTime         : int  1527670800 1527757200 1527840000 1527940800 1528016400 1528102800 1528185600 1528272000
##  $ apparentTemperatureHigh    : num  83.5 69.5 72.6 76.4 66 ...
##  $ apparentTemperatureHighTime: int  1527620400 1527703200 1527793200 1527886800 1527966000 1528056000 1528135200 1528214400
##  $ apparentTemperatureLow     : num  52.9 46.8 60.1 60.2 45.9 ...
##  $ apparentTemperatureLowTime : int  1527670800 1527757200 1527840000 1527940800 1528016400 1528102800 1528185600 1528272000
##  $ dewPoint                   : num  57 47.1 52.2 65 58.1 ...
##  $ humidity                   : num  0.72 0.63 0.76 0.94 0.87 0.8 0.73 0.7
##  $ pressure                   : num  1014 1023 1017 1007 1007 ...
##  $ windSpeed                  : num  0.6 4.31 5.86 4.39 5.47 7.34 3.67 7.29
##  $ windGust                   : num  11.3 17.1 16.9 13.6 28.4 ...
##  $ windGustTime               : int  1527649200 1527674400 1527782400 1527829200 1527933600 1528005600 1528138800 1528239600
##  $ windBearing                : int  259 105 181 172 59 62 0 346
##  $ cloudCover                 : num  0.25 0.48 0.73 0.81 1 0.38 0.85 1
##  $ uvIndex                    : int  8 6 7 6 5 8 6 6
##  $ uvIndexTime                : int  1527609600 1527696000 1527782400 1527868800 1527955200 1528041600 1528131600 1528218000
##  $ visibility                 : num  9.52 10 9.42 10 NA NA NA NA
##  $ ozone                      : num  342 327 316 311 312 ...
##  $ temperatureMin             : num  52.2 51.7 48.1 59.8 56.1 ...
##  $ temperatureMinTime         : POSIXct, format: "2018-05-29 03:00:00" "2018-05-30 23:00:00" "2018-05-31 05:00:00" "2018-06-01 04:00:00" ...
##  $ temperatureMax             : num  83.5 69.5 72.6 75.4 66.9 ...
##  $ temperatureMaxTime         : POSIXct, format: "2018-05-29 15:00:00" "2018-05-30 14:00:00" "2018-05-31 15:00:00" "2018-06-01 17:00:00" ...
##  $ apparentTemperatureMin     : num  52.2 51.7 46.8 60.1 56.1 ...
##  $ apparentTemperatureMinTime : POSIXct, format: "2018-05-29 03:00:00" "2018-05-30 23:00:00" "2018-05-31 05:00:00" "2018-06-01 04:00:00" ...
##  $ apparentTemperatureMax     : num  83.5 69.5 72.6 76.4 67.8 ...
##  $ apparentTemperatureMaxTime : POSIXct, format: "2018-05-29 15:00:00" "2018-05-30 14:00:00" "2018-05-31 15:00:00" "2018-06-01 17:00:00" ...
## NULL
## 
## currently 
## ======================================================================================================================== 
## 'data.frame':    1 obs. of  19 variables:
##  $ time                : POSIXct, format: "2018-05-29 15:54:44"
##  $ summary             : chr "Clear"
##  $ icon                : chr "clear-day"
##  $ nearestStormDistance: int 119
##  $ nearestStormBearing : int 234
##  $ precipIntensity     : int 0
##  $ precipProbability   : int 0
##  $ temperature         : num 83.2
##  $ apparentTemperature : num 83.2
##  $ dewPoint            : num 56.8
##  $ humidity            : num 0.41
##  $ pressure            : num 1014
##  $ windSpeed           : num 2.52
##  $ windGust            : num 6.88
##  $ windBearing         : int 137
##  $ cloudCover          : num 0.02
##  $ uvIndex             : int 3
##  $ visibility          : num 7.44
##  $ ozone               : num 343
## NULL

Historical (using Date objects):

seq(Sys.Date()-10, Sys.Date(), "1 day") %>% 
  map(~get_forecast_for(43.2672, -70.8617, .x)) %>% 
  map_df("hourly") %>% 
  ggplot(aes(x=time, y=temperature)) +
  geom_line()
<img src="README_files/figure-gfm/unnamed-chunk-6-1.png" width="672" />
then <- get_forecast_for(43.2672, -70.8617, "2013-05-06T12:00:00-0400", add_headers=TRUE)
print(then)
## hourly 
## ======================================================================================================================== 
## 'data.frame':    24 obs. of  14 variables:
##  $ time               : POSIXct, format: "2013-05-06 00:00:00" "2013-05-06 01:00:00" "2013-05-06 02:00:00" "2013-05-06 03:00:00" ...
##  $ summary            : chr  "Clear" "Clear" "Clear" "Clear" ...
##  $ icon               : chr  "clear-night" "clear-night" "clear-night" "clear-night" ...
##  $ precipIntensity    : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ precipProbability  : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ temperature        : num  4

Related Skills

View on GitHub
GitHub Stars81
CategoryDevelopment
Updated5mo ago
Forks10

Languages

R

Security Score

82/100

Audited on Oct 6, 2025

No findings