The InsightR package contains wrapper functions for interacting with the Insight API: http://docs.api.wdtinc.com/insight-api/en/latest/.

API authorization tokens may be obtained from here: http://wdtinc.com/skywise-home/insight-api/

Basic Usage

Before making any calls you will need to set your app_id and app_key

Authenticate("your_app_id", "your_app_key")

Set up some variables to make calls with

lat <- 35
lon <- -97
start <- '2016-01-01'
end <- '2016-01-31'

gdd <- GrowingDegreeDays (lat, lon, start, end)  
gdd$response$status_code == 200
[1] TRUE

summary(gdd$content$series[[3]])
  Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.0000  0.0000  0.0000  0.4581  0.0000  5.2000 

Hourly endpoints are only available for a 10 day timespan

hp = HourlyPrecipitation(lat, lon, start, end)
Warning message:
In .call.api("hourly-precipitation", latitude, longitude, start,  :
Unprocessable Entity (WebDAV; RFC 4918) (HTTP 422).

hp$response$status_code
[1] 422

hp$content$message
[1] "Your date/datetime query exceeded the maximum timespan of this resource."

hp = HourlyPrecipitation(lat, lon, "2017-01-01", "2017-01-10")
hp$response$status_code == 200
[1] TRUE

summary(hp$content$series[[3]])
  Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.00000 0.00000 0.00000 0.02745 0.00000 3.58000 

Daily endpoints can be up to 1 year in length

cdd <- CoolingDegreeDays(lat, lon, "2016-01-01", "2016-12-31")
summary(cdd$content$series[[3]])
 Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.000   0.000   2.600   4.813   9.600  15.800

Put the series into graphable form

dp <- DailyPrecipitation(35.235762, -97.428966, "2017-05-01", "2017-06-13")
x <- as.Date(dp$content$series[[1]], "%Y-%m-%d")
y <- dp$content$series[[3]]
sum(y)
[1] 39.44
plot(x,y, xlab="date", ylab="precip in mm")


wdtinc/InsightR documentation built on May 24, 2019, 7:50 a.m.