View source: R/get_metno_forecast.R
| get_metno_forecast | R Documentation |
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
)
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 |
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 |
cache_dir |
Character. Optional directory path for cache files. If
|
allow_stale_on_error |
Logical. If |
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.
Rodrigo Pires, rodrigo.pires@dpird.wa.gov.au
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()
## Not run:
forecast <- get_metno_forecast(
latitude = -31.95,
longitude = 115.86,
api_key = "your.email@example.com"
)
forecast$metadata$expires
utils::head(forecast$data)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.