Retrieves weather forecast data from the Norwegian Meteorological Institute
locationforecast API and returns the parsed metadata together with a tidy hourly
data.table. The response headers Expires and Last-Modified are provided
both in their raw RFC 1123 form and parsed to POSIXct for downstream logic.
get_metno_forecast(
latitude,
longitude,
format = c("compact", "complete"),
api_key = get_key(service = "METNO"),
timeout = 30,
max_retries = 3,
retry_delay = 1,
use_cache = TRUE,
cache_dir = NULL,
allow_stale_on_error = TRUE
)A named list with elements:
dataHourly forecast as a data.table.
rawThe full parsed GeoJSON response (list).
metadataA list containing request parameters, status code, retrieval timestamp,
header information (expires_raw, expires, last_modified_raw,
last_modified), and cache provenance in metadata$cache.
Numeric. Latitude in decimal degrees for the forecast location. Must be within Australian limits (-44 to -10).
Numeric. Longitude in decimal degrees for the forecast location. Must be within Australian limits (112 to 154).
Character. Either "compact" (default) or "complete" for the
MET Weather API locationforecast endpoint variant.
Character. Email address required for the User-Agent header in accordance with MET Weather API terms of service.
Numeric. Request timeout in seconds (default: 30).
Integer. Maximum number of retry attempts on transient failures (default: 3).
Numeric. Base delay between retries in seconds for exponential backoff (default: 1).
Logical. Use session-scoped cache and conditional
revalidation for MET.NO responses. Defaults to TRUE.
Character. Optional directory path for cache files. If
NULL (default), uses file.path(tempdir(), "metno_cache").
Logical. If TRUE (default), return stale cached
data when MET.NO returns HTTP 429 (rate limit exceeded) and stale cache is
available.
Rodrigo Pires, [email protected]
Other METNO:
get_metno_daily_forecast(),
metno_get_dominant_symbol(),
metno_resample_data_table(),
metno_timeseries_to_data_table()
Other data fetching:
get_coastal_forecast(),
get_data_drill(),
get_data_drill_apsim(),
get_dpird_apsim(),
get_dpird_extremes(),
get_dpird_minute(),
get_dpird_summaries(),
get_metno_daily_forecast(),
get_patched_point(),
get_patched_point_apsim(),
get_precis_forecast(),
get_radar_imagery(),
get_satellite_imagery()
if (FALSE) {
forecast <- get_metno_forecast(
latitude = -31.95,
longitude = 115.86,
api_key = "[email protected]"
)
forecast$metadata$expires
utils::head(forecast$data)
}
Run the code above in your browser using DataLab