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

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

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.

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.

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

# \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"))
#> station: 12330
#> http://www.ogimet.com/cgi-bin/getsynop?block=12330&begin=200912010000&end=200912042359
#> Downloaded 32 SYNOP messages for: 12330

  # Daily HTML summaries for New York - La Guardia (default source = "html")
  new_york = meteo_ogimet(interval = "daily", station  = 72503)
#> Daily raports will be generated for 6 UTC each day. Use the >>hour<< argument to change it 
#> station: 72503
#> INFO: Please note that the Ogimet has recently limited number of queries that are accepted
#>         
 by the server from a single IP address. Therefore, downloading more than 1 month of data
#>         
 for a single station requires 20 seconds pause between subsequent queries and
#>         
 may take a while. Thank you for your patience.

  # 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)
#> station: 12330
#> http://www.ogimet.com/cgi-bin/getsynop?block=12330&begin=200912010000&end=200912042359
#> Downloaded 32 SYNOP messages for: 12330
  head(poznan_list$data)  # simplified
#>                  date station t2m dpt2m rel_hum tmax tmin  wd ws gust press
#> 1 2009-12-01 00:00:00   12330 4.3   3.7    95.9   NA   NA  NA  0   NA 989.4
#> 2 2009-12-01 03:00:00   12330 5.2   4.0    92.0   NA   NA  10  1   NA 989.3
#> 3 2009-12-01 06:00:00   12330 5.4   4.5    93.9  5.8  2.9  10  2   NA 989.7
#> 4 2009-12-01 09:00:00   12330 6.3   4.9    90.8   NA   NA  40  3   NA 990.9
#> 5 2009-12-01 12:00:00   12330 6.2   4.8    90.7   NA   NA  10  3   NA 992.0
#> 6 2009-12-01 15:00:00   12330 6.0   5.1    94.0   NA   NA 340  3   NA 993.7
#>      slp press_tend precip Nt Nh N_base insol visibility snow
#> 1 1000.2        0.8      0  7  7   1500    NA       3500   NA
#> 2 1000.1       -0.1     NA  7  3   1500    NA      10000   NA
#> 3 1000.4        0.4      0  8  8    100   3.1       8000   NA
#> 4 1001.6        1.2     NA  8  8    100    NA       2500   NA
#> 5 1002.7        1.1      0  8  8    100    NA       2400   NA
#> 6 1004.5        1.7     NA  8  8    100    NA       2200   NA
  head(poznan_list$full)  # all parser columns
#>   station_id                Date station_type region obs_day obs_hour wind_unit
#> 1      12330 2009-12-01 00:00:00         AAXX     VI       1        0       m/s
#> 2      12330 2009-12-01 03:00:00         AAXX     VI       1        3       m/s
#> 3      12330 2009-12-01 06:00:00         AAXX     VI       1        6       m/s
#> 4      12330 2009-12-01 09:00:00         AAXX     VI       1        9       m/s
#> 5      12330 2009-12-01 12:00:00         AAXX     VI       1       12       m/s
#> 6      12330 2009-12-01 15:00:00         AAXX     VI       1       15       m/s
#>   wind_estimated visibility cloud_cover wind_direction wind_speed
#> 1          FALSE       3500           7             NA          0
#> 2          FALSE      10000           7             10          1
#> 3          FALSE       8000           8             10          2
#> 4          FALSE       2500           8             40          3
#> 5          FALSE       2400           8             10          3
#> 6          FALSE       2200           8            340          3
#>   air_temperature dewpoint_temperature station_pressure sea_level_pressure
#> 1             4.3                  3.7            989.4             1000.2
#> 2             5.2                  4.0            989.3             1000.1
#> 3             5.4                  4.5            989.7             1000.4
#> 4             6.3                  4.9            990.9             1001.6
#> 5             6.2                  4.8            992.0             1002.7
#> 6             6.0                  5.1            993.7             1004.5
#>   pressure_tendency pressure_change precipitation_amount precipitation_time
#> 1                 2             0.8                    0                 12
#> 2                 8            -0.1                   NA                 NA
#> 3                 2             0.4                    0                 18
#> 4                 2             1.2                   NA                 NA
#> 5                 2             1.1                    0                 12
#> 6                 3             1.7                   NA                 NA
#>   cloud_base_min cloud_base_max low_cloud_type middle_cloud_type
#> 1           1500           2000              5                NA
#> 2           1500           2000              5                 3
#> 3            100            200              5                NA
#> 4            100            200              5                NA
#> 5            100            200              6                NA
#> 6            100            200              6                NA
#>   high_cloud_type low_cloud_amount maximum_temperature minimum_temperature gust
#> 1              NA                7                  NA                  NA   NA
#> 2              NA                3                  NA                  NA   NA
#> 3              NA                8                 5.8                 2.9   NA
#> 4              NA                8                  NA                  NA   NA
#> 5              NA                8                  NA                  NA   NA
#> 6              NA                8                  NA                  NA   NA
#>   cloudiness_height sunshine_duration snow_depth snow_depth_state
#> 1                NA                NA         NA               NA
#> 2                NA                NA         NA               NA
#> 3                NA               3.1         NA               NA
#> 4                NA                NA         NA               NA
#> 5                NA                NA         NA               NA
#> 6                NA                NA         NA               NA
#>                                                                                                                  source
#> 1                               AAXX 01001 12330 11735 70000 10043 20037 39894 40002 52008 60001 71042 875// 333 93000=
#> 2                                                     AAXX 01031 12330 42760 70101 10052 20040 39893 40001 58001 8353/=
#> 3 AAXX 01061 12330 11258 80102 10054 20045 39897 40004 52004 60002 71022 885// 333 10058 20029 31001 55031 81704 93000=
#> 4                                     AAXX 01091 12330 41225 80403 10063 20049 39909 40016 52012 71022 885// 333 85706=
#> 5                         AAXX 01121 12330 11224 80103 10062 20048 39920 40027 52011 69901 72122 886// 333 88706 93097=
#> 6                                     AAXX 01151 12330 41222 83403 10060 20051 39937 40045 53017 71062 886// 333 88704=

  # Country mode: all Polish stations for one day
  germany = meteo_ogimet(interval      = "hourly",
                         country_name  = "Germany",
                         date          = c("2009-12-15", "2009-12-15"))
#> Downloading country: Germany
#> http://www.ogimet.com/cgi-bin/getsynop?begin=200912150000&end=200912152359&state=Germany
#> Could not retrieve data for: Germany
#> No SYNOP data returned for: Germany

  # Force SYNOP backend for daily data
  poznan_d = meteo_ogimet(interval = "daily",
                          station  = 12330,
                          date     = c("2009-12-01", "2009-12-04"),
                          source   = "synop")
#> station: 12330
#> http://www.ogimet.com/cgi-bin/getsynop?block=12330&begin=200912010000&end=200912042359
#> Could not retrieve data for: 12330
#> No SYNOP data returned for: 12330

  # Force HTML backend for hourly data
  poznan_h2 = meteo_ogimet(interval = "hourly",
                           station  = 12330,
                           date     = c("2019-06-01", "2019-06-08"),
                           source   = "html")
#> station:  12330
#> INFO: Please note that the Ogimet has recently limited number of queries that are accepted
#>         
 by the server from a single IP address. Therefore, downloading more than approx. 1 day of data
#>         
 for a single station requires 20 seconds pause between subsequent queries and
#>         
 may take a while. Thank you for your patience.
# }