Learn R Programming

climate (version 1.4.1)

meteo_ogimet: Download meteorological (Synop) data from the Ogimet service

Description

Unified entry point for downloading hourly or daily meteorological data from Ogimet. Two backends are supported:

Usage

meteo_ogimet(
  interval = "hourly",
  date = c(Sys.Date() - 30, Sys.Date()),
  station = NULL,
  country_name = NULL,
  source = NULL,
  ...
)

Value

synop output (source = "synop", simplified = TRUE or return_list = TRUE

$data): A data.frame with one row per decoded SYNOP observation and approx. 20 columns: date (POSIXct UTC), station, t2m, dpt2m, rel_hum, tmax, tmin, wd, ws, gust, press, slp, press_tend, precip, Nt, Nh, N_base, insol, visibility, snow.

synop output (source = "synop", simplified = FALSE): A data.frame with 30+ columns from synop_parser(), prefixed by station_id

and Date.

html output (source = "html", interval = "hourly"): A data.frame with columns: station_ID, optionally Lon/Lat, Date, TC, TdC, TmaxC, TminC, ddd, ffkmh, Gustkmh, P0hPa, PseahPa, PTnd, Nt, Nh, HKm, InsoD1, Viskm, Snowcm, and (when precip_split = TRUE) pr6, pr12, pr24.

html output (source = "html", interval = "daily"): A data.frame with columns: station_ID, optionally Lon/Lat, Date, TemperatureCAvg, TemperatureCMax, TemperatureCMin, TdAvgC, HrAvg, WindkmhDir, WindkmhInt, WindkmhGust, PresslevHp, PreselevHp, Precmm, SunD1h, SnowDepcm, TotClOct, lowClOct, VisKm.

Returns NULL invisibly on failure when allow_failure = TRUE.

Arguments

interval

"hourly" (default) or "daily" — time resolution to retrieve.

date

Length-2 character or Date vector giving the start and end of the requested period, e.g. c("2018-05-01", "2018-07-01"). Defaults to the last 30 days.

station

WMO ID(s) of the station(s) to download. Character or numeric vector. Not required when country_name is provided (SYNOP path only).

country_name

Optional character string. When provided, the SYNOP path downloads all Ogimet stations for the named country in a single request (e.g. "Poland", "Germany"), and station is ignored. Valid only with source = "synop" (or the default hourly path).

source

Character. Backend to use: "synop" (raw SYNOP decoding) or "html" (HTML scraping). When NULL (default) the backend is chosen automatically: "synop" for interval = "hourly", "html" for interval = "daily".

...

Optional named arguments:

allow_failure

Logical. When TRUE (default) network or parsing errors are caught and a message is emitted; when FALSE errors propagate.

simplified

Logical. Applies to source = "synop" only. When TRUE (default) a compact 20-column data.frame is returned (see synop output below). When FALSE the full synop_parser() output is returned with 30+ columns.

precip_split

Logical. Split the precipitation field into separate pr6, pr12, and pr24 columns. Valid only for interval = "hourly" with source = "html"; a warning is emitted otherwise. Default TRUE.

return_list

Logical. Applies to source = "synop" only. When TRUE a named list with elements data (compact 20-column data.frame) and full (30+ column parser output) is returned instead of a data.frame. A warning is emitted when used with source = "html". Default FALSE.

Details

  • "synop" (default for hourly): Downloads raw SYNOP messages from the Ogimet getsynop endpoint and decodes them with synop_parser(). Supports station mode (one or more WMO IDs) and/or country mode (country_name). A default output columns are described in the synop output section below, but can be enhanced optionally with simplified = FALSE or return_list = TRUE to include more of decoded SYNOP fields.

  • "html" (default for daily): Scrapes pre-formatted summary tables from the Ogimet using HTML parsing. Supports station mode only (one or more WMO IDs). Output columns are described in the html output section below.

Examples

Run this code
# \donttest{
  # Hourly SYNOP data for Poznan-Lawica (default source = "synop")
  poznan_h = meteo_ogimet(interval = "hourly",
                          station  = 12330,
                          date     = c("2009-12-01", "2009-12-04"))

  # Daily HTML summaries for New York - La Guardia (default source = "html")
  new_york = meteo_ogimet(interval = "daily", station  = 72503)

  # Hourly with full parser output as a list
  poznan_list = meteo_ogimet(interval     = "hourly",
                             station      = 12330,
                             date         = c("2009-12-01", "2009-12-04"),
                             return_list  = TRUE)
  head(poznan_list$data)  # simplified
  head(poznan_list$full)  # all parser columns

  # Country mode: all Polish stations for one day
  germany = meteo_ogimet(interval      = "hourly",
                         country_name  = "Germany",
                         date          = c("2009-12-15", "2009-12-15"))

  # Force SYNOP backend for daily data
  poznan_d = meteo_ogimet(interval = "daily",
                          station  = 12330,
                          date     = c("2009-12-01", "2009-12-04"),
                          source   = "synop")

  # Force HTML backend for hourly data
  poznan_h2 = meteo_ogimet(interval = "hourly",
                           station  = 12330,
                           date     = c("2019-06-01", "2019-06-08"),
                           source   = "html")
# }

Run the code above in your browser using DataLab