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.
Arguments
- latitude
Numeric. Latitude in decimal degrees for the forecast location. Must be within Australian limits (-44 to -10).
- longitude
Numeric. Longitude in decimal degrees for the forecast location. Must be within Australian limits (112 to 154).
- format
Character. Either
"compact"(default) or"complete"for the MET Weather API locationforecast endpoint variant.- api_key
Character. Email address required for the User-Agent header in accordance with MET Weather API terms of service.
- timeout
Numeric. Request timeout in seconds (default: 30).
- max_retries
Integer. Maximum number of retry attempts on transient failures (default: 3).
- retry_delay
Numeric. Base delay between retries in seconds for exponential backoff (default: 1).
- use_cache
Logical. Use session-scoped cache and conditional revalidation for MET.NO responses. Defaults to
TRUE.- cache_dir
Character. Optional directory path for cache files. If
NULL(default), usesfile.path(tempdir(), "metno_cache").- allow_stale_on_error
Logical. If
TRUE(default), return stale cached data when MET.NO returns HTTP 429 (rate limit exceeded) and stale cache is available.
Value
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 inmetadata$cache.
See also
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()
Author
Rodrigo Pires, rodrigo.pires@dpird.wa.gov.au
Examples
if (FALSE) { # \dontrun{
forecast <- get_metno_forecast(
latitude = -31.95,
longitude = 115.86,
api_key = "your.email@example.com"
)
forecast$metadata$expires
utils::head(forecast$data)
} # }
