Weather forecasts, reports on current weather conditions, astronomical information and alerts at a specific location based on the ‘HERE Destination Weather’ API.
In order to request information about the current weather situation points of interest (POIs) have to be provided. The POIs must be an sf object containing geometries of type POINT or a character vector containing place names (e.g. cities). These POIs are passed to the weather() function, whereby the product parameter is set to "observation":
The return value is an sf object, which contains the POINT geometries of the provided POIs and the most recent record on the observed weather. The measurements are taken from the nearest weather observation stations with respect to the POIs. The distance of the stations to the provided POIs is an indicator for the reliabilty of the weather information at each POI. A table of the observed weather near the example POIs:
| station | distance | description | temperature | humidity | windSpeed | windDirection |
|---|---|---|---|---|---|---|
| Rönnimoos | 450 | Partly sunny. Quite cool. | 7.00 | 57 | 7.41 | 300 |
| Lugano | 670 | Passing clouds. Refreshingly cool. | 13.00 | 24 | 16.68 | 10 |
| Chailly | 340 | Cool. | 7.61 | 64 | 5.56 | 210 |
| Kleinhüningen | 430 | Partly sunny. Quite cool. | 7.00 | 66 | 9.27 | 250 |
| Kehrsatz | 620 | Partly sunny. Quite cool. | 6.00 | 66 | 5.56 | 0 |
| Zürich (Kreis 6) / Oberstrass | 820 | Overcast. Quite cool. | 6.00 | 53 | 11.12 | 250 |
| Geneva | 490 | Broken clouds. Cool. | 8.00 | 57 | 11.12 | 280 |
| Vaduz | 940 | Quite cool. | 6.11 | 69 | 1.85 | 170 |
Print the weather observation information on an interactive leaflet map:
An hourly forecast of the predicted weather for the following seven days can be obtained by setting the product parameter to "forecast_hourly"
Print the weather observation information on an interactive leaflet map with popup graphs for temperature and humidity:
g <- lapply(1:nrow(forecast), function(x) {
fc <- forecast$forecast[[x]]
ggplot() +
geom_line(aes(x = seq(1, nrow(fc)), y = as.numeric(fc$temperature)),
colour = 'red') +
geom_line(aes(x = seq(1, nrow(fc)), y = as.numeric(fc$humidity)),
colour = 'blue') +
xlab("Time from now [h]") +
ylab("Temperature [°C] / Humidity [%]") +
ggtitle(forecast$city[x]) +
theme_classic()
})popup parameter:An astronomical forecast is requested by setting the product parameter to "forecast_astronomy":
| date | sunrise | sunset | moonrise | moonset | phase |
|---|---|---|---|---|---|
| 2019-11-13 | 7:26AM | 4:54PM | 5:47PM | 8:03AM | Full moon |
| 2019-11-14 | 7:28AM | 4:53PM | 6:23PM | 9:11AM | Waning gibbous |
| 2019-11-15 | 7:29AM | 4:52PM | 7:07PM | 10:17AM | Waning gibbous |
| 2019-11-16 | 7:31AM | 4:51PM | 8:01PM | 11:18AM | Waning gibbous |
| 2019-11-17 | 7:32AM | 4:50PM | 9:04PM | 12:12PM | Waning gibbous |
| 2019-11-18 | 7:34AM | 4:49PM | 10:14PM | 12:57PM | Waning gibbous |
| 2019-11-19 | 7:35AM | 4:48PM | 11:29PM | 1:35PM | Last Quarter |
| 2019-11-20 | 7:37AM | 4:47PM |
|
2:07PM | Last Quarter |
Current weather alerts, near provided POIs, are obtain by the product alerts:
This returns an sf object with the POIs and the attribute "alerts", which is a data.table, which contains the current weather alerts. If no alerts are recorded near a POI the attribute "alerts" is NULL.