Destination Weather API

Weather forecasts, reports on current weather conditions, astronomical information and alerts at a specific location based on the ‘HERE Destination Weather’ API.

Observations

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":

observation <- weather(
  poi = poi,
  product = "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 Light rain. Mostly cloudy. Cool. 14.00 88 7.41 50
Lugano 670 Sunny. Mild. 20.00 64 5.56 0
Chailly 340 Cool. 15.11 85 3.71 180
Kleinhüningen 430 Low clouds. Cool. 8.00 100 11.12 340
Kehrsatz 620 Broken clouds. Cool. 15.00 82 7.41 290
Zürich (Kreis 6) / Oberstrass 820 Cloudy. Cool. 11.00 94 7.41 350
Geneva 490 Partly sunny. Cool. 15.00 88 3.71 0
Vaduz 940 Sprinkles. Cloudy. Cool. 13.39 92 0.00 0

Print the weather observation information on an interactive leaflet map:

mapview(observation,
        zcol = "temperature",
        cex = observation$humidity/4,
        layer.name = "Observation",
        map.types = c("Esri.WorldTopoMap"),
        homebutton = FALSE
)

Forecast

An hourly forecast of the predicted weather for the following seven days can be obtained by setting the product parameter to "forecast_hourly"

forecast <- weather(
  poi = poi,
  product = "forecast_hourly"
)

Print the weather observation information on an interactive leaflet map with popup graphs for temperature and humidity:

  1. Create a list containing the temperature and humidity graphs for every POI:
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()
})
  1. Then add list of graphs to the leaflet map using the the popup parameter:
mapview(forecast,
        color = "black",
        col.region = "yellow",
        layer.name = "Forecast",
        zcol = "city",
        map.types = c("Esri.WorldTopoMap"),
        homebutton = FALSE,
        legend = FALSE,
        popup = leafpop::popupGraph(g)
)

Astronomy

An astronomical forecast is requested by setting the product parameter to "forecast_astronomy":

astronomy <- weather(
  poi = poi,
  product = "forecast_astronomy"
)
Print a table for the sun and moon times of the first example POI, where the nearest station is ‘Emmenbrücke’:
date sunrise sunset moonrise moonset phase
2019-10-28 7:03AM 5:17PM 7:03AM 5:54PM New moon
2019-10-29 7:04AM 5:15PM 8:22AM 6:25PM New moon
2019-10-30 7:06AM 5:14PM 9:39AM 7:02PM Waxing crescent
2019-10-31 7:07AM 5:12PM 10:50AM 7:45PM Waxing crescent
2019-11-01 7:09AM 5:11PM 11:53AM 8:34PM Waxing crescent
2019-11-02 7:10AM 5:09PM 12:47PM 9:30PM Waxing crescent
2019-11-03 7:12AM 5:08PM 1:33PM 10:29PM Waxing crescent
2019-11-04 7:13AM 5:06PM 2:09PM 11:31PM First Quarter

Alerts

Current weather alerts, near provided POIs, are obtain by the product alerts:

alerts <- weather(
  poi = poi,
  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.

API Reference