| Title: | Interface to Download Meteorological (and Hydrological) Datasets |
|---|---|
| Description: | Automatize downloading of meteorological and hydrological data from publicly available repositories: OGIMET (<http://ogimet.com/index.phtml.en>), University of Wyoming - atmospheric vertical profiling data (<http://weather.uwyo.edu/upperair/>), Polish Institute of Meteorology and Water Management - National Research Institute (<https://danepubliczne.imgw.pl>), and National Oceanic & Atmospheric Administration (NOAA). This package also allows for searching geographical coordinates for each observation and calculate distances to the nearest stations. |
| Authors: | Bartosz Czernecki [aut, cre] (ORCID: <https://orcid.org/0000-0001-6496-1386>), Arkadiusz Głogowski [aut] (ORCID: <https://orcid.org/0000-0002-7587-8892>), Jakub Nowosad [aut] (ORCID: <https://orcid.org/0000-0002-1057-3721>), IMGW-PIB [ctb] (source of the data) |
| Maintainer: | Bartosz Czernecki <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.4.2 |
| Built: | 2026-10-02 00:36:49 UTC |
| Source: | https://github.com/bczernecki/climate |
The object contains pre-downloaded CO2 dataset from Mauna Loa observatory The snapshot was taken 2020/05/05.
co2_democo2_demo
An object of class data.frame with 745 rows and 7 columns.
data.frame with historical CO2 concentrations data(co2_demo) head(co2_demo)
Uses the August-Roche-Magnus approximation to derive relative humidity from the 2-metre air temperature and dew-point temperature.
compute_relative_humidity(t2m, dpt2m)compute_relative_humidity(t2m, dpt2m)
t2m |
Numeric vector. Air temperature (2 m) in degrees Celsius. |
dpt2m |
Numeric vector. Dew-point temperature (2 m) in degrees Celsius.
Must be the same length as |
The August-Roche-Magnus approximation is:
where is the air temperature and is the dew-point
temperature, both in degrees Celsius. The coefficients (17.625 and 243.04)
follow Alduchov & Eskridge (1996).
Numeric vector of relative humidity values in percent (0-100).
Returns NA where either input is NA. Values are not clamped, so
rounding errors may produce results marginally outside 0-100.
Alduchov, O. A., & Eskridge, R. E. (1996). Improved Magnus form approximation of saturation vapor pressure. Journal of Applied Meteorology, 35(4), 601–609.
compute_relative_humidity(t2m = 20, dpt2m = 10) # ~52 % compute_relative_humidity(t2m = 0, dpt2m = 0) # 100 % compute_relative_humidity(t2m = c(20, 15, NA), dpt2m = c(10, 12, 8))compute_relative_humidity(t2m = 20, dpt2m = 10) # ~52 % compute_relative_humidity(t2m = 0, dpt2m = 0) # 100 % compute_relative_humidity(t2m = c(20, 15, NA), dpt2m = c(10, 12, 8))
For IMGW-PIB stations different naming were used historically. For example,
POZNAŃ and “POZNAŃ-ŁAWICA, thus both names should be used when searching
for the station. This function finds all variants of station' names
status information and expand the created object
find_all_station_names(station_name)find_all_station_names(station_name)
station_name |
character vector of station names |
character vector of station names with all variants of station's names
{ find_all_station_names(c("WARSZAWA", "POZNAŃ")) }{ find_all_station_names(c("WARSZAWA", "POZNAŃ")) }
Downloading daily, and monthly hydrological data from the measurement stations available in the danepubliczne.imgw.pl collection
hydro_imgw(interval, year, value = "H", station = NULL, ...)hydro_imgw(interval, year, value = "H", station = NULL, ...)
interval |
temporal resolution of the data ("daily" or "monthly") |
year |
vector of years (e.g., 1966:2000) |
value |
type of data (can be: state - "H" (default), flow - "Q", or temperature - "T") |
station |
vector of hydrological stations danepubliczne.imgw.pl; can be given as station name with CAPITAL LETTERS (character) It accepts either names (characters in CAPITAL LETTERS) or stations' IDs (numeric) |
... |
other parameters that may be passed e.g. to the 'shortening' function that shortens column names |
A data.frame with columns describing the hydrological parameters
(e.g. flow, water level) where each row represent a measurement,
depending on the interval, at a given hour, month or year.
IMGW parameter columns carry a label attribute with the original metadata label.
If coords = TRUE additional two columns with geographic coordinates are added.
x = hydro_imgw("monthly", year = 1999) head(x)x = hydro_imgw("monthly", year = 1999) head(x)
Downloading daily hydrological data from the danepubliczne.imgw.pl collection
hydro_imgw_daily(year, station = NULL, allow_failure = TRUE, ...)hydro_imgw_daily(year, station = NULL, allow_failure = TRUE, ...)
year |
vector of years (e.g., 1966:2000) |
station |
name or ID of hydrological station(s). It accepts names (characters in CAPITAL LETTERS) or stations' IDs (numeric) |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
other parameters that may be passed to the 'shortening' function that shortens column names |
data.frame with historical hydrological data for the daily time interval
daily = hydro_imgw_daily(year = 2000)daily = hydro_imgw_daily(year = 2000)
Downloading hourly and sub-hourly (hydrological) data from the telemetric stations available in the danepubliczne.imgw.pl/datastore collection since 2008. Most parameters are collected with 10 minutes interval and thus it is recommended to download only the mandatory years, parameters or stations. For example, 1 year of data with all available parameters requires processing around 2-4GB of uncompressed data.
hydro_imgw_datastore( year, parameters = NULL, stations = NULL, coords = TRUE, allow_failure = TRUE )hydro_imgw_datastore( year, parameters = NULL, stations = NULL, coords = TRUE, allow_failure = TRUE )
year |
numeric vector of years to be downloaded (e.g., 2022:2023) |
parameters |
|
stations |
|
coords |
|
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
Data from the IMGW automated (telemetry) systems are non validated by experts and may contain invalid values.
data.table with a raw hydrorological measurements in 10-min or 60-min intervals. Please note that this dataset is not validated by experts and may contain invalid values.
imgw_hydro_telemetry = hydro_imgw_datastore(year = 2022, parameters = "flow", stations = "FORDON", coords = TRUE)imgw_hydro_telemetry = hydro_imgw_datastore(year = 2022, parameters = "flow", stations = "FORDON", coords = TRUE)
Downloading monthly hydrological data from the danepubliczne.imgw.pl collection
hydro_imgw_monthly( year, coords = FALSE, station = NULL, allow_failure = TRUE, ... )hydro_imgw_monthly( year, coords = FALSE, station = NULL, allow_failure = TRUE, ... )
year |
vector of years (e.g., 1966:2000) |
coords |
add coordinates of the stations (logical value TRUE or FALSE) |
station |
name or ID of hydrological station(s). It accepts names (characters in CAPITAL LETTERS) or stations' IDs (numeric) |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
other parameters that may be passed to the 'shortening' function that shortens column names |
data.frame with historical hydrological data for the monthly summaries
monthly = hydro_imgw_monthly(year = 2000)monthly = hydro_imgw_monthly(year = 2000)
Shortening column names of hydrological parameters to improve the readability of downloaded dataset from the danepubliczne.imgw.pl collection and removing duplicated column names
hydro_shortening_imgw(data, remove_duplicates = TRUE)hydro_shortening_imgw(data, remove_duplicates = TRUE)
data |
downloaded dataset with original column names |
remove_duplicates |
whether to remove duplicated column names (default TRUE - i.e., columns with duplicated names are deleted) |
data.frame with short English names of hydrological parameters.
Existing column attributes, including the original IMGW label metadata,
are preserved.
monthly = data = hydro_imgw("monthly", year = 1969) if (is.data.frame(monthly)) { abbr = hydro_shortening_imgw(data = monthly, remove_duplicates = TRUE) head(abbr) }monthly = data = hydro_imgw("monthly", year = 1969) if (is.data.frame(monthly)) { abbr = hydro_shortening_imgw(data = monthly, remove_duplicates = TRUE) head(abbr) }
The object contains 3 columns that are currently used for improving readability of the downloaded dataset: fullname, abbr_eng, and fullname_eng
imgw_hydro_abbrevimgw_hydro_abbrev
The data contains a data.frame with ca. 20 elements described in three ways:
original column names as downloaded from the repository
shorten column names with abbreviations derived from the most popular scheme used for meteorological parameters
detailed description of downloaded meteorological variables
The object is created mostly to be used altogether with the hydro_shortening_imgw() function
data(imgw_hydro_abbrev) head(imgw_hydro_abbrev)data(imgw_hydro_abbrev) head(imgw_hydro_abbrev)
The object contains weather stations coordinates, ID numbers, and elevations
imgw_hydro_stationsimgw_hydro_stations
The data contains a data.frame with 1304 obs. of 3 variables:
Station ID
Longitude
Latitude
The object is in the geographic coordinates using WGS84 (EPSG:4326).
data(imgw_hydro_stations) head(imgw_hydro_stations)data(imgw_hydro_stations) head(imgw_hydro_stations)
The object contains 3 columns that are currently used for improving readability of the downloaded dataset: fullname, abbr_eng, and fullname_eng
imgw_meteo_abbrevimgw_meteo_abbrev
The data contains a data.frame with ca. 250 elements described in three ways:
original column names as downloaded from the repository
shorten column names with abbreviations derived from the most popular scheme used for meteorological parameters
detailed description of downloaded meteorological variables
The object is created mostly to be used altogether with the meteo_shortening_imgw function
data(imgw_meteo_abbrev) head(imgw_meteo_abbrev)data(imgw_meteo_abbrev) head(imgw_meteo_abbrev)
The object contains weather stations coordinates, ID numbers, and elevations
imgw_meteo_stationsimgw_meteo_stations
The data contains a data.frame with 1998 obs. of 3 variables:
Station ID
Longitude
Latitude
Station name
IMGW-PIB ID for station rank
The object is in the geographic coordinates using WGS84 (EPSG:4326).
data(imgw_meteo_stations) head(imgw_meteo_stations)data(imgw_meteo_stations) head(imgw_meteo_stations)
Downloading hourly, daily, and monthly meteorological data from the SYNOP / CLIMATE / PRECIP stations, or sub-hourly (10-minute) telemetry data from the automated network, all available in the danepubliczne.imgw.pl collection.
meteo_imgw( interval = NULL, rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, parameters = NULL, ... )meteo_imgw( interval = NULL, rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, parameters = NULL, ... )
interval |
temporal resolution of the data: |
rank |
rank of the stations: |
year |
vector of years (e.g., |
status |
leave the columns with measurement and observation statuses
(default |
coords |
add coordinates of the station (logical value |
station |
name of meteorological station(s).
For ranks |
parameters |
character vector of parameter codes to download.
Only used when |
... |
other parameters passed to the column-shortening function. Not used when
|
A data.frame with meteorological parameters where each row is a measurement.
For ranks "synop", "climate", "precip": measurements at a given hour, day, or month,
depending on interval. If coords = TRUE two additional coordinate columns are appended.
IMGW parameter columns also carry a label attribute with the original Polish metadata label.
For rank = "telemetry": a data.table with 10-minute interval observations (not
expert-validated). If coords = TRUE columns name, lon, lat, and alt are appended.
x = meteo_imgw("monthly", year = 2018, coords = TRUE) head(x) # Telemetry (10-minute) data from automated stations (available since 2008): tel = meteo_imgw(rank = "telemetry", year = 2022, parameters = "t2m", station = "HALA GĄSIENICOWA") head(tel)x = meteo_imgw("monthly", year = 2018, coords = TRUE) head(x) # Telemetry (10-minute) data from automated stations (available since 2008): tel = meteo_imgw(rank = "telemetry", year = 2022, parameters = "t2m", station = "HALA GĄSIENICOWA") head(tel)
Downloading daily (meteorological) data from the SYNOP / CLIMATE / PRECIP stations available in the danepubliczne.imgw.pl collection
meteo_imgw_daily( rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, allow_failure = TRUE, ... )meteo_imgw_daily( rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, allow_failure = TRUE, ... )
rank |
rank of the stations: "synop" (default), "climate", or "precip" |
year |
vector of years (e.g., 1966:2000) |
status |
leave the columns with measurement and observation statuses (default status = FALSE - i.e. the status columns are deleted) |
coords |
add coordinates of the station (logical value TRUE or FALSE) |
station |
name of meteorological station(s).
It accepts vector of names (characters in CAPITAL LETTERS);
Important: Some stations may have changed names over time in the IMGW-PIB
database and thus providing both names is needed
(e.g. |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
other parameters that may be passed to the 'shortening' function that shortens column names |
data.frame with a daily meteorological measurements
daily = meteo_imgw_daily(rank = "climate", year = 2000)daily = meteo_imgw_daily(rank = "climate", year = 2000)
Downloading hourly (meteorological) data from the telemetric stations available in the danepubliczne.imgw.pl/datastore collection since 2008. Most parameters are collected with 10 minutes interval and thus it is recommended to download only the mandatory years, parameters or stations. For example, 1 year of data with all available parameters requires processing around 4GB of uncompressed data.
meteo_imgw_datastore( year, parameters = NULL, stations = NULL, coords = TRUE, allow_failure = TRUE )meteo_imgw_datastore( year, parameters = NULL, stations = NULL, coords = TRUE, allow_failure = TRUE )
year |
numeric vector of years to be downloaded (e.g., 2022:2023) |
parameters |
|
stations |
|
coords |
|
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
Data from the IMGW automated (telemetry) systems are non validated by experts and may contain invalid values.
data.table with a raw meteorological measurements in 10-min intervals. Please note that this dataset is not validated by experts and may contain invalid values.
imgw_telemetry = meteo_imgw_datastore(year = 2022:2023, parameters = "t2m", stations = c("HALA GĄSIENICOWA", "DOLINA 5 STAWÓW"), coords = TRUE)imgw_telemetry = meteo_imgw_datastore(year = 2022:2023, parameters = "t2m", stations = c("HALA GĄSIENICOWA", "DOLINA 5 STAWÓW"), coords = TRUE)
Downloading hourly (meteorological) data from the SYNOP / CLIMATE / PRECIP stations available in the danepubliczne.imgw.pl collection
meteo_imgw_hourly( rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, allow_failure = TRUE, ... )meteo_imgw_hourly( rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, allow_failure = TRUE, ... )
rank |
rank of the stations: "synop" (default), "climate", or "precip" |
year |
vector of years (e.g., 1966:2000) |
status |
leave the columns with measurement and observation statuses (default status = FALSE - i.e. the status columns are deleted) |
coords |
add coordinates of the station (logical value TRUE or FALSE) |
station |
name of meteorological station(s) (character vector) |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
other parameters that may be passed to the 'shortening' function that shortens column names |
meteorological data for the hourly time interval
hourly = meteo_imgw_hourly(rank = "climate", year = 1984) head(hourly)hourly = meteo_imgw_hourly(rank = "climate", year = 1984) head(hourly)
Downloading monthly (meteorological) data from the SYNOP / CLIMATE / PRECIP stations available in the danepubliczne.imgw.pl collection
meteo_imgw_monthly( rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, allow_failure = TRUE, ... )meteo_imgw_monthly( rank = "synop", year, status = FALSE, coords = FALSE, station = NULL, allow_failure = TRUE, ... )
rank |
rank of the stations: "synop" (default), "climate", or "precip" |
year |
vector of years (e.g., 1966:2000) |
status |
leave the columns with measurement and observation statuses (default status = FALSE - i.e. the status columns are deleted) |
coords |
add coordinates of the station (logical value TRUE or FALSE) |
station |
name of meteorological station(s).
It accepts names (characters in CAPITAL LETTERS). Stations' IDs (numeric) are no longer supported.
Please note that station names may change over time and thus sometimes 2 names
are required in some cases, e.g. |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
other parameters that may be passed to the 'shortening' function that shortens column names |
meteorological data with monthly summaries
monthly = meteo_imgw_monthly(rank = "climate", year = 1969) head(monthly)monthly = meteo_imgw_monthly(rank = "climate", year = 1969) head(monthly)
Carbon Dioxide (CO2) monthly measurements from Mauna Loa observatory. The source file is available at: ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt with all further details.
meteo_noaa_co2()meteo_noaa_co2()
Data from March 1958 through April 1974 have been obtained by C. David Keeling of the Scripps Institution of Oceanography (SIO) and were obtained from the Scripps website (scrippsco2.ucsd.edu).
The "average" column contains the monthly mean CO2 mole fraction determined from daily averages. The mole fraction of CO2, expressed as parts per million (ppm) is the number of molecules of CO2 in every one million molecules of dried air (water vapor removed). If there are missing days concentrated either early or late in the month, the monthly mean is corrected to the middle of the month using the average seasonal cycle. Missing months are denoted by -99.99. The "interpolated" column includes average values from the preceding column and interpolated values where data are missing. Interpolated values are computed in two steps. First, we compute for each month the average seasonal cycle in a 7-year window around each monthly value. In this way the seasonal cycle is allowed to change slowly over time. We then determine the "trend" value for each month by removing the seasonal cycle; this result is shown in the "trend" column. Trend values are linearly interpolated for missing months. The interpolated monthly mean is then the sum of the average seasonal cycle value and the trend value for the missing month. NOTE: In general, the data presented for the last year are subject to change, depending on recalibration of the reference gas mixtures used, and other quality control procedures. Occasionally, earlier years may also be changed for the same reasons. Usually these changes are minor. CO2 expressed as a mole fraction in dry air, micromol/mol, abbreviated as ppm
Data frame with historical CO2 concentrations
co2 = meteo_noaa_co2() head(co2)co2 = meteo_noaa_co2() head(co2)
Downloading hourly (meteorological) data from the SYNOP stations available in the NOAA ISD collection. Some stations in the dataset are dated back even up to 1900. By default only records that follow FM-12 (SYNOP) convention are processed. Further details available at: https://www.ncei.noaa.gov/pub/data/noaa/readme.txt
meteo_noaa_hourly( station = NULL, year = 2019, fm12 = TRUE, allow_failure = TRUE )meteo_noaa_hourly( station = NULL, year = 2019, fm12 = TRUE, allow_failure = TRUE )
station |
ID of meteorological station(s) (characters). Find your station's ID at: https://www.ncei.noaa.gov/pub/data/noaa/isd-history.txt |
year |
vector of years (e.g., 1966:2000) |
fm12 |
use only FM-12 (SYNOP) records (TRUE by default) |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
data.frame with historical meteorological data in hourly intervals
# London-Heathrow, United Kingdom noaa = meteo_noaa_hourly(station = "037720-99999", year = 1949)# London-Heathrow, United Kingdom noaa = meteo_noaa_hourly(station = "037720-99999", year = 1949)
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, ... )meteo_ogimet( interval = "hourly", date = c(Sys.Date() - 30, Sys.Date()), station = NULL, country_name = NULL, source = NULL, ... )
interval |
|
date |
Length-2 character or Date vector giving the start and end of
the requested period, e.g. |
station |
WMO ID(s) of the station(s) to download. Character or numeric
vector. Not required when |
country_name |
Optional character string. When provided, the SYNOP path
downloads all Ogimet stations for the named country in a single request
(e.g. |
source |
Character. Backend to use: |
... |
Optional named arguments:
|
"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.
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.
# 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")# 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")
Downloads raw SYNOP messages from the Ogimet getsynop endpoint and decodes
them into a tidy data.frame using the synop_parser() function. Two retrieval
modes are supported:
meteo_ogimet_synop( station = NULL, date = c(Sys.Date() - 30, Sys.Date()), country = NULL, country_name = NULL, simplified = TRUE, allow_failure = TRUE )meteo_ogimet_synop( station = NULL, date = c(Sys.Date() - 30, Sys.Date()), country = NULL, country_name = NULL, simplified = TRUE, allow_failure = TRUE )
station |
Numeric or character vector of WMO station IDs. Optional when
|
date |
Character or Date vector of length 2 giving the start and end of
the requested period, e.g. |
country |
Optional; passed to |
country_name |
Optional character string naming the country whose
stations should be downloaded, as recognised by Ogimet (e.g.
|
simplified |
Logical. When |
allow_failure |
Logical. When |
Station mode (station provided): fetches messages for one or more
WMO station IDs.
URL form: http://www.ogimet.com/cgi-bin/getsynop?block=<id>&begin=<YYYYMMDDhhmm>&end=<YYYYMMDDhhmm>
Country mode (country_name provided): fetches messages for all
Ogimet stations in a country in a single request.
URL form: http://www.ogimet.com/cgi-bin/getsynop?begin=<YYYYMMDDhhmm>&end=<YYYYMMDDhhmm>&state=<country_name>
When both station and country_name are supplied, country_name takes
precedence and a warning is issued.
Each line of the response is a comma-separated record:
station_id,year,month,day,hour,minute,<SYNOP message>.
The SYNOP message is decoded via synop_parser() with as_data_frame = TRUE.
By default (simplified = TRUE), a compact data.frame with one
row per decoded SYNOP observation. Columns:
date — Observation date-time (POSIXct, UTC).
station — WMO station identifier (character).
t2m — Air temperature at 2 m (°C).
dpt2m — Dew-point temperature at 2 m (°C).
rel_hum — Relative humidity (%), derived via compute_relative_humidity().
tmax — Daily maximum temperature from Section 3 (°C).
tmin — Daily minimum temperature from Section 3 (°C).
wd — Wind direction (degrees).
ws — Wind speed (m/s or knots, per wind_unit).
gust — Highest gust speed from Section 3, same unit as ws.
press — Station-level pressure (hPa).
slp — Sea-level pressure (hPa).
press_tend — 3-hour pressure change (hPa).
precip — Precipitation amount (mm).
Nt — Total cloud cover (oktas, 0–8) from the Nddff group.
Nh — Cover of low clouds (genera Sc, St, Cu, Cb) in oktas (0–8),
from Section 1 group 8NhCLCMCH; NA when not reported.
N_base — Height of base of lowest observed cloud (m).
insol — Daily sunshine duration (hours).
visibility — Horizontal visibility (m).
snow — Total snow depth (cm); 0 for trace amounts.
When simplified = FALSE, a data.frame with the first two columns
station_id (WMO identifier, character) and Date (POSIXct, UTC),
followed by all columns produced by synop_parser() with as_data_frame = TRUE:
station_type, region, obs_day, obs_hour, wind_unit,
wind_estimated, visibility, cloud_cover, wind_direction,
wind_speed, air_temperature, dewpoint_temperature,
station_pressure, sea_level_pressure, pressure_tendency,
pressure_change, precipitation_amount, precipitation_time,
cloud_base_min, cloud_base_max, low_cloud_type, middle_cloud_type,
high_cloud_type, low_cloud_amount, maximum_temperature,
minimum_temperature, gust, sunshine_duration,
snow_depth, snow_depth_state, source.
Returns NULL invisibly when the download fails and allow_failure = TRUE.
# Station mode: Poznan-Lawica (Poland) poznan = meteo_ogimet_synop(station = 12330, date = c("2009-12-01", "2009-12-04")) head(poznan) # Station mode: multiple stations two_stations = meteo_ogimet_synop(station = c(12330, 12375), date = c("2019-06-01", "2019-06-03")) head(two_stations) # Country mode: all Polish stations for one day poland = meteo_ogimet_synop(country_name = "Poland", date = c("2009-12-15", "2009-12-15")) head(poland) # Simplified view poznan_simple = meteo_ogimet_synop(station = 12330, date = c("2009-12-01", "2009-12-04"), simplified = TRUE) head(poznan_simple)# Station mode: Poznan-Lawica (Poland) poznan = meteo_ogimet_synop(station = 12330, date = c("2009-12-01", "2009-12-04")) head(poznan) # Station mode: multiple stations two_stations = meteo_ogimet_synop(station = c(12330, 12375), date = c("2019-06-01", "2019-06-03")) head(two_stations) # Country mode: all Polish stations for one day poland = meteo_ogimet_synop(country_name = "Poland", date = c("2009-12-15", "2009-12-15")) head(poland) # Simplified view poznan_simple = meteo_ogimet_synop(station = 12330, date = c("2009-12-01", "2009-12-04"), simplified = TRUE) head(poznan_simple)
Shortening column names of meteorological parameters to improve the readability of downloaded dataset from the danepubliczne.imgw.pl collection and removing duplicated column names
meteo_shortening_imgw(data, remove_duplicates = TRUE)meteo_shortening_imgw(data, remove_duplicates = TRUE)
data |
downloaded dataset with original column names |
remove_duplicates |
whether to remove duplicated column names (default TRUE - i.e., columns with duplicated names are deleted) |
data.frame with short English names of meteorological parameters.
Existing column attributes, including the original IMGW label metadata,
are preserved.
monthly = meteo_imgw("monthly", rank = "climate", year = 1969) abbr = meteo_shortening_imgw(data = monthly, remove_duplicates = TRUE) head(abbr)monthly = meteo_imgw("monthly", rank = "climate", year = 1969) abbr = meteo_shortening_imgw(data = monthly, remove_duplicates = TRUE) head(abbr)
Returns a data frame of meteorological or hydrological stations with their coordinates in particular year.
The returned object is valid only for a given year and type of stations (e.g. "synop", "climate" or "precip"). If add_map = TRUE additional map of downloaded data is added.
nearest_stations_imgw( type = "meteo", rank = "synop", year = 2018, add_map = TRUE, point = NULL, no_of_stations = 50, allow_failure = TRUE, ... )nearest_stations_imgw( type = "meteo", rank = "synop", year = 2018, add_map = TRUE, point = NULL, no_of_stations = 50, allow_failure = TRUE, ... )
type |
data name; "meteo" (default), "hydro" |
rank |
rank of the stations: "synop" (default), "climate", or "precip"; Only valid if type = "meteo" |
year |
select year for searching nearest station |
add_map |
logical - whether to draw a map for a returned data frame (requires maps/mapdata packages) |
point |
a vector of two coordinates (longitude, latitude) for a point we want to find nearest stations to (e.g. c(15, 53)); If not provided calculated as a mean longitude and latitude for the entire dataset |
no_of_stations |
how many nearest stations will be returned from the given geographical coordinates. 50 used by default |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
extra arguments to be provided to the |
A data.frame with a list of nearest stations. Each row represents metadata for station which collected measurements in a given year. Particular columns contain stations metadata (e.g. station ID, geographical coordinates, official name, distance in kilometers from a given coordinates).
df = nearest_stations_imgw(type = "meteo", rank = "synop", year = 2018, point = c(17, 52), add_map = TRUE, no_of_stations = 4)df = nearest_stations_imgw(type = "meteo", rank = "synop", year = 2018, point = c(17, 52), add_map = TRUE, no_of_stations = 4)
Returns a data frame of meteorological stations with their coordinates and distance from a given location based on the noaa website. The returned list is valid only for a given day.
nearest_stations_noaa( country, date = Sys.Date(), add_map = TRUE, point = NULL, no_of_stations = 10, allow_failure = TRUE )nearest_stations_noaa( country, date = Sys.Date(), add_map = TRUE, point = NULL, no_of_stations = 10, allow_failure = TRUE )
country |
country name (e.g., "SRI LANKA"). Single entries allowed only. |
date |
optionally, a day when measurements were done in all available locations; current Sys.Date used by default |
add_map |
logical - whether to draw a map for a returned data frame (requires maps/mapdata packages) |
point |
a vector of two coordinates (longitude, latitude) for a point we want to find nearest stations to (e.g. c(80, 6)). If not provided the query will be based on a mean longitude and latitude among available dataset. |
no_of_stations |
how many nearest stations will be returned from the given geographical coordinates; default 30 |
allow_failure |
logical - whether to allow or stop on failure. By default set to TRUE. For debugging purposes change to FALSE |
A data.frame with number of nearest station according to given point columns describing stations parameters
(e.g. ID station, distance from point, geographic coordinates, etc.) where each row represent a measurement,
each station which has a measurements on selected date. If add_map = TRUE additional map of downloaded data is added.
nearest_stations_noaa(country = "SRI LANKA", point = c(80, 6), add_map = TRUE, no_of_stations = 10) uk_stations = nearest_stations_noaa(country = "UNITED KINGDOM", no_of_stations = 100)nearest_stations_noaa(country = "SRI LANKA", point = c(80, 6), add_map = TRUE, no_of_stations = 10) uk_stations = nearest_stations_noaa(country = "UNITED KINGDOM", no_of_stations = 100)
Returns a data frame of meteorological stations with their coordinates and distance from a given location based on the ogimet webpage. The returned list is valid only for a given day.
nearest_stations_ogimet( country = "United Kingdom", date = Sys.Date() - 1, add_map = FALSE, point = c(2, 50), no_of_stations = 10, allow_failure = TRUE, ... )nearest_stations_ogimet( country = "United Kingdom", date = Sys.Date() - 1, add_map = FALSE, point = c(2, 50), no_of_stations = 10, allow_failure = TRUE, ... )
country |
country name; It is possible to provide more than one country combined into a vector |
date |
optionally, a day when measurements were done in all available locations; |
add_map |
logical - whether to draw a map for a returned data frame (requires maps/mapdata packages) |
point |
a vector of two coordinates (longitude, latitude) for a point we want to find nearest stations to (e.g. c(0, 0)) |
no_of_stations |
how many nearest stations will be returned from the given geographical coordinates |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
extra arguments to be provided to the |
A data.frame with number of nearest station according to given point columns describing stations parameters
(e.g. ID station, distance from point in km, geographic coordinates, etc.). Each row represent a measurement,
each station which has a measurements on selected date. If add_map = TRUE additional map of downloaded data is added.
nearest_stations_ogimet(country = "United Kingdom", point = c(-2, 50), add_map = TRUE, no_of_stations = 50, allow_failure = TRUE, main = "Meteo stations in UK")nearest_stations_ogimet(country = "United Kingdom", point = c(-2, 50), add_map = TRUE, no_of_stations = 50, allow_failure = TRUE, main = "Meteo stations in UK")
Downloading daily (meteorological) data from the Synop stations available in the https://www.ogimet.com/ repository. The data are processed only if temperature or precipitation fields are present.
ogimet_daily( date = c(Sys.Date() - 30, Sys.Date()), station = NA, hour = 6, allow_failure = TRUE, ... )ogimet_daily( date = c(Sys.Date() - 30, Sys.Date()), station = NA, hour = 6, allow_failure = TRUE, ... )
date |
start and finish of date (e.g., date = c("2018-05-01","2018-07-01") ). By default last 30 days. |
station |
WMO ID of meteorological station(s). Character or numeric vector |
hour |
time for which the daily raport is generated. Set default as hour = 6 (i.e. 6 UTC) |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
... |
extra arguments that may be passed from wrapper top-level functions |
data.frame with historical meteorological data for the daily summaries
# downloading daily summaries for last 30 days. station: New York - La Guardia new_york = ogimet_daily(station = 72503)# downloading daily summaries for last 30 days. station: New York - La Guardia new_york = ogimet_daily(station = 72503)
The object contains pre-downloaded atmospheric (sounding) profile for Leba, PL rawinsonde station. The measurement was taken 2000/03/23 at 00 UTC.
profile_demoprofile_demo
The data contains list of two data.frames as derived using sounding_wyoming() function
data(profile_demo) head(profile_demo)data(profile_demo) head(profile_demo)
Downloading the measurements of the vertical profile of atmosphere (also known as sounding data). Data can be retrieved using TEMP and BUFR sounding formatting. By default automatic detection of input format is used.
sounding_wyoming( wmo_id, yy, mm, dd, hh, min = 0, source = "AUTODETECT", allow_failure = TRUE )sounding_wyoming( wmo_id, yy, mm, dd, hh, min = 0, source = "AUTODETECT", allow_failure = TRUE )
wmo_id |
international WMO station code (World Meteorological Organization ID); For Polish stations: Leba - 12120, Legionowo - 12374, Wrocław - 12425 |
yy |
year - calendar year |
mm |
month - calendar month |
dd |
day - calendar day |
hh |
hour - hour of sounding; for most stations measurements are performed twice a day (i.e. at 12 and 00 UTC), sporadically 4 times a day |
min |
minute - minute of sounding; Default 00; Other values applies only to BUFR soundings. |
source |
|
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
Returns two lists with values described at: weather.uwyo.edu ; The first list contains:
PRES - Pressure (hPa)
HGHT - Height (metres)
TEMP - Temperature (C)
DWPT - Dew point (C)
RELH - Relative humidity (%)
MIXR - Mixing ratio (g/kg)
DRCT - Wind direction (deg)
SPED - Wind speed (m/s)
THTA - (K)
THTE - (K)
THTV - (K)
The second list contains metadata for time of observation and station location
A list of 2 data.frames where first data frame represents parameters of upper parts o with columns describing the meteorogical parameters (e.g. temperature, air pressure) where each row represent a measurement, depending on the height. Second data.frame presents a description of the conditions under which the sounding was carried out.
http://weather.uwyo.edu/upperair/sounding.html
# download data for Station 45004 starting 1120Z 11 Jul 2021; Kowloon, HONG KONG, CHINA # using AUTODETECT, TEMP and BUFR sounding formats # autodect input format: sounding_auto = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17, hh = 12) # temp (fm35) input format: sounding_temp = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17, hh = 12, source = "TEMP") # bufr input format: sounding_bufr = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17, hh = 12, min = 00, source = "BUFR")# download data for Station 45004 starting 1120Z 11 Jul 2021; Kowloon, HONG KONG, CHINA # using AUTODETECT, TEMP and BUFR sounding formats # autodect input format: sounding_auto = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17, hh = 12) # temp (fm35) input format: sounding_temp = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17, hh = 12, source = "TEMP") # bufr input format: sounding_bufr = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17, hh = 12, min = 00, source = "BUFR")
Calculate the distance between two points on the surface of a spheroid using Vincenty's formula. This function can be used when GIS libraries for calculating distance are not available.
spheroid_dist(p1, p2)spheroid_dist(p1, p2)
p1 |
coordinates of the first point in decimal degrees (LON, LAT) |
p2 |
coordinates of the second point in decimal degrees (LON, LAT) |
numerical vector with distance between two locations (in kilometers)
p1 = c(18.633333, 54.366667) # longitude and latitude for Gdansk, PL p2 = c(17.016667, 54.466667) # longitude and latitude for Slupsk, PL spheroid_dist(p1, p2)p1 = c(18.633333, 54.366667) # longitude and latitude for Gdansk, PL p2 = c(17.016667, 54.466667) # longitude and latitude for Slupsk, PL spheroid_dist(p1, p2)
Retrieving current metadata for hydrological stations used in the telemetric systems of the IMGW-PIB datastore (danepubliczne.imgw.pl/datastore)
stations_hydro_imgw_telemetry()stations_hydro_imgw_telemetry()
data table with metadata for over 850 stations. Metadata contains: station ID, station name, river, latitude, longitude, altitude, km_of_river
hydro_telemetry_stations = stations_hydro_imgw_telemetry()hydro_telemetry_stations = stations_hydro_imgw_telemetry()
Retrieving current metadata for meteorological stations used in the telemetric systems of the IMGW-PIB datastore (danepubliczne.imgw.pl/datastore)
stations_meteo_imgw_telemetry()stations_meteo_imgw_telemetry()
data table with metadata for over 500 stations. Metadata contains: station ID, station name, river, year_est, latitude, longitude, altitude
meteo_telemetry_stations = stations_meteo_imgw_telemetry()meteo_telemetry_stations = stations_meteo_imgw_telemetry()
Returns a list of meteorological stations with their coordinates from the Ogimet webpage. The returned list is valid only for a given day
stations_ogimet( country = "United Kingdom", date = Sys.Date(), add_map = FALSE, allow_failure = TRUE )stations_ogimet( country = "United Kingdom", date = Sys.Date(), add_map = FALSE, allow_failure = TRUE )
country |
country name; Every word must be written with capital letters (e.g. "United Kingdom") |
date |
a day when measurements were done in all available locations |
add_map |
logical - whether to draw a map based on downloaded dataset (requires |
allow_failure |
logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE |
A data.frame with columns describing the synoptic stations in selected countries where each row represent a statation.
If add_map = TRUE additional map of downloaded data is visualized.
stations_ogimet(country = "Australia", add_map = TRUE)stations_ogimet(country = "Australia", add_map = TRUE)
This function decodes SYNOP FM-12 meteorological messages which are commonly
used for reporting weather observations under the regulations of the World Meteorological Organization (WMO).
It parses one or more SYNOP messages and
returns their structured representation as generated by the SYNOP R6
decoder.
synop_parser(message, country = NULL, simplify = TRUE, as_data_frame = FALSE)synop_parser(message, country = NULL, simplify = TRUE, as_data_frame = FALSE)
message |
Character vector with SYNOP messages. |
country |
Optional; A single character value passed to the precipitation
indicator decoder to adjust country-specific behaviour (e.g. |
simplify |
Logical. If |
as_data_frame |
Logical. If |
Currently, the decoder contains most of the core logic for parsing the main sections of SYNOP messages that are commonly used in atmospheric sciences. However, it does not yet cover all possible SYNOP groups and fields, and some fields may be missing or incomplete.
When as_data_frame = FALSE (default): a list of decoded SYNOP
messages, or the decoded list directly when simplify = TRUE and a single
message is supplied. When as_data_frame = TRUE: a data.frame with one
row per message and the following columns (all numeric/character as
appropriate, NA when not present in the message):
station_type, station_id, region, obs_day, obs_hour,
wind_unit, wind_estimated, visibility, cloud_cover,
wind_direction, wind_speed, air_temperature, dewpoint_temperature,
station_pressure, sea_level_pressure, pressure_tendency,
pressure_change, precipitation_amount, precipitation_time,
cloud_base_min, cloud_base_max, low_cloud_type,
middle_cloud_type, high_cloud_type, low_cloud_amount,
maximum_temperature (Section 3 daily maximum, °C),
minimum_temperature (Section 3 daily minimum, °C),
gust (highest gust speed from Section 3 group 910ff/911ff, in the wind unit of the message),
cloudiness_height (cloud cover in oktas of the highest cloud layer reported in Section 3,
i.e. cirrus/cirrocumulus/cirrostratus; NA when absent),
sunshine_duration (daily sunshine in hours, from Section 3 group 55SSS),
snow_depth (total snow depth in cm; 0 for trace amounts, NA for non-continuous cover or
unmeasurable depth), snow_depth_state (descriptive state of ground with snow/ice per WMO
code table 0975, e.g. "Even layer of loose dry snow covering ground completely"),
source (the original SYNOP message string).
Row names are sequential integers.
synop_code = "AAXX 01004 88889 12782 61506 10094 20047 30111 40197 53007 60001 81541" synop_parser(synop_code) synop_parser(rep(synop_code, 2), simplify = FALSE) synop_parser(synop_code, as_data_frame = TRUE) synop_parser(rep(synop_code, 2), as_data_frame = TRUE)synop_code = "AAXX 01004 88889 12782 61506 10094 20047 30111 40197 53007 60001 81541" synop_parser(synop_code) synop_parser(rep(synop_code, 2), simplify = FALSE) synop_parser(synop_code, as_data_frame = TRUE) synop_parser(rep(synop_code, 2), as_data_frame = TRUE)
Function for downloading & testing url/internet connection according to CRAN policy Example solution strongly based on https://community.rstudio.com/t/internet-resources-should-fail-gracefully/49199/12 as suggested by kvasilopoulos
test_url(link, output, quiet = TRUE)test_url(link, output, quiet = TRUE)
link |
character vector with URL to check |
output |
character vector for output file name |
quiet |
logical vector (TRUE or FALSE) to be passed to curl_download function. FALSE by default |
No return value, called for side effects
link = "https://www.ncei.noaa.gov/pub/data/noaa/2019/123300-99999-2019.gz" output = tempfile() test_url(link = link, output = output)link = "https://www.ncei.noaa.gov/pub/data/noaa/2019/123300-99999-2019.gz" output = tempfile() test_url(link = link, output = output)