climate

July 10, 2026 · View on GitHub

R-CMD-check HTML5 check Codecov test
coverage CRAN
status CRAN RStudio mirror
downloads

The goal of the climate R package is to automatize downloading of in-situ meteorological and hydrological data from publicly available repositories:

  • OGIMET (ogimet.com) - up-to-date collection of SYNOP dataset
  • University of Wyoming - atmospheric vertical profiling data (http://weather.uwyo.edu/upperair/)
  • National Oceanic & Atmospheric Administration - Earth System Research Laboratories - Global Monitoring Laboratory (NOAA)
  • Polish Institute of Meteorology and Water Management - National Research Institute (IMGW-PIB)
  • National Centers for Environmental Information, National Oceanic & Atmospheric Administration - National Climatic Data Center - Integrated Surface Hourly (ISH) (NOAA)

Installation

The stable release of the climate package from the CRAN repository can be installed with:

install.packages("climate")

It is also possible to install the most up-to-date development version of climate from GitHub with:

library(remotes)
install_github("bczernecki/climate")

Overview

Meteorological data

  • 🌍 meteo_ogimet - Downloading hourly and daily meteorological data from the SYNOP stations available in the ogimet.com collection. Any meteorological (aka SYNOP) station working under the World Meteorological Organization framework after year 2000 should be accessible. Two backends are available and selected automatically: raw SYNOP decoding (source = "synop", default for interval = "hourly") and HTML scraping (source = "html", default for interval = "daily"). Country-level bulk downloads are supported via the country_name argument (SYNOP backend only).

  • 🌍 meteo_noaa_hourly - Downloading hourly NCEI/NOAA Integrated Surface Hourly (ISH) meteorological data - Some stations have > 100 years long history of observations

  • 🌍 meteo_noaa_co2 - Downloading monthly CO2 measurements from Mauna Loa Observatory

  • 🌍 sounding_wyoming - Downloading measurements of the vertical profile of atmosphere (aka rawinsonde data)

  • 🇵🇱 meteo_imgw - Downloading hourly, daily, and monthly meteorological data from the Polish met service across all types of stations (i.e. SYNOP/CLIMATE/PRECIP ) available in the danepubliczne.imgw.pl collection. It is a wrapper for meteo_monthly(), meteo_daily(), meteo_hourly() and meteo_imgw_datastore() which gives access from montly to even to 10-min dataset.

(Polish) Hydrological data

  • 🇵🇱 hydro_imgw - Downloading hourly, daily, and monthly hydrological data from stations available in the danepubliczne.imgw.pl collection. It is a wrapper for previously developed set of functions such as: hydro_monthly(), and hydro_daily()

  • 🇵🇱 hydro_imgw_datastore - Downloading hourly and subhourly hydrological data from the IMGW-PIB hydro telemetry stations.

Auxiliary functions and datasets

  • 🌍 stations_ogimet - Downloading information about all stations available in the selected country in the Ogimet repository

  • 🌍 nearest_stations_ogimet - Downloading information about nearest stations to the selected point using Ogimet repository

  • 🌍 nearest_stations_noaa - Downloading information about nearest stations to the selected point available for the selected country in the NOAA ISH meteorological repository

  • 🇵🇱 nearest_stations_imgw - List of nearby meteorological or hydrological IMGW-PIB stations in Poland

  • 🇵🇱 imgw_meteo_stations - Built-in metadata from the IMGW-PIB repository for meteorological stations, their geographical coordinates, and ID numbers

  • 🇵🇱 imgw_hydro_stations - as above, for hydrological stations

  • 🇵🇱 stations_meteo_imgw_telemetry - Downloading complete and up-to-date information about coordinates for IMGW-PIB telemetry meteorological stations

  • 🇵🇱 stations_hydro_imgw_telemetry - Downloading complete and up-to-date information about coordinates for IMGW-PIB telemetry hydrological stations

  • 🌍 synop_parser - Decoding raw SYNOP meteorological messages into structured R lists or data frames. For a full walkthrough see the SYNOP Messages vignette.

Example 1

Download hourly dataset from NCEI/NOAA ISH meteorological repository:

library(climate)
noaa = meteo_noaa_hourly(station = "123300-99999", year = 2018:2019) # station ID: Poznan, Poland
head(noaa)
yearmonthdayhourlonlataltt2mdpt2mwswdslpvisibility
201911016.8552.417843.32.352201025.06000
201911116.8552.417843.73.042201024.21500
201911216.8552.417844.23.642201022.51300
201911316.8552.417845.24.652401021.21900

Example 2

Finding a nearest meteorological stations in a given country using NCEI/NOAA ISH data source (used in Ex. 1):

# find 100 nearest UK stations to longitude 1W and latitude 53N :

nearest_stations_ogimet(country = "United Kingdom",
  date = Sys.Date(),
  add_map = TRUE,
  point = c(-1, 53),
  no_of_stations = 100
)
wmo_idstation_nameslonlataltdistance [km]
03354Nottingham Weather Centre-1.25000553.0000011728.04973
03379Cranwell-0.50001053.033336756.22175
03377Waddington-0.51667753.166676857.36093
03373Scampton-0.55001153.300015760.67897
03462Wittering-0.46667652.616688473.68934
03544Church Lawford-1.33334052.3666710780.29844
..................

100 nearest stations to given coordinates in UK

Example 3

Downloading daily (or hourly) data from a global (OGIMET) repository knowing its ID (see also nearest_stations_ogimet()):

# Daily summary — uses HTML backend by default
o = meteo_ogimet(date = c(Sys.Date() - 5, Sys.Date() - 1), 
                 interval = "daily",
                 station = 12330)
head(o)
station_IDDateTempCAvgTempCMaxTempCMinTdAvgCHrAvgWindDirWindIntWindGustPressHpPrecmmTotClOctlowClOctSunD1hVisKm
123302019-12-218.813.24.95.379.3SSE11.439.6995.91.83.62.06.721.4
123302019-12-205.48.5-1.24.592.4ESE15.0NA1015.00.06.40.61.08.0
123302019-12-193.810.3-3.01.989.6SW7.1NA1020.40.05.25.92.514.1
123302019-12-186.39.02.24.184.8S9.2NA1009.20.05.72.71.412.2
123302019-12-174.97.60.32.987.2SSE7.2NA1010.80.16.24.6NA13.0
# Hourly observations — decoded from raw SYNOP messages by default
h = meteo_ogimet(date = c("2009-12-01", "2009-12-04"),
                 interval = "hourly",
                 station  = 12330)
head(h)
datestationt2mdpt2mrel_humtmaxtminwdwsgustpressslpprecipNtsnow
2009-12-01 00:00:00123302.00.093NANA2105NA1007.41016.3NA8NA
2009-12-01 06:00:00123301.0-1.092NANA2003NA1009.81018.8NA8NA
2009-12-01 12:00:00123303.01.0935.82.92304NA1011.51020.4NA8NA
2009-12-01 18:00:00123302.00.093NANA2403NA1013.31022.1NA7NA
# Country-level bulk download — all stations in a country for a given day
poland = meteo_ogimet(interval      = "hourly",
                      country_name  = "Poland",
                      date          = c("2009-12-15", "2009-12-15"))
nrow(poland)  #> several hundred rows (one per observation per station)

Example 4

Downloading monthly/daily/hourly meteorological/hydrological data from the Polish (IMGW-PIB) repository:

m = meteo_imgw(interval = "monthly", rank = "synop", year = 2000, coords = TRUE)
head(m)
rankidXYstationyymmtmax_abstmax_meantmin_abstmin_meant2m_mean_mont5cm_minrr_monthly
SYNOP35323029523.1622853.10726BIAŁYSTOK200015.30.4-16.5-4.5-2.1-23.534.2
SYNOP35323029523.1622853.10726BIAŁYSTOK2000210.64.1-10.4-1.41.3-12.925.4
SYNOP35323029523.1622853.10726BIAŁYSTOK2000314.86.2-6.4-1.02.4-9.445.5
SYNOP35323029523.1622853.10726BIAŁYSTOK2000427.817.9-4.64.711.5-8.131.6
SYNOP35323029523.1622853.10726BIAŁYSTOK2000529.321.3-4.35.713.8-8.39.4
SYNOP35323029523.1622853.10726BIAŁYSTOK2000632.623.11.09.616.6-1.836.4
h = hydro_imgw(interval = "daily", year = 2010:2011)
head(h)
idstationriv_or_lakedatehyyidhyyddHQTmmthick
150210180ANNOPOLWisła (2)2009-11-01201011287436NA11NA
150210180ANNOPOLWisła (2)2009-11-02201012282412NA11NA
150210180ANNOPOLWisła (2)2009-11-03201013272368NA11NA
150210180ANNOPOLWisła (2)2009-11-04201014268352NA11NA
150210180ANNOPOLWisła (2)2009-11-05201015264336NA11NA
150210180ANNOPOLWisła (2)2009-11-06201016260320NA11NA

Example 5

Create Walter & Lieth climatic diagram based on downloaded data

library(climate)
library(dplyr)

df = meteo_imgw(interval = "monthly", rank = "synop", year = 1991:2019, station = "POZNAŃ") 
df2 = select(df, station:t2m_mean_mon, rr_monthly)

monthly_summary = df2 %>% 
  group_by(mm) %>% 
  summarise(tmax = mean(tmax_abs, na.rm = TRUE), 
            tmin = mean(tmin_abs, na.rm = TRUE),
            tavg = mean(t2m_mean_mon, na.rm = TRUE), 
            prec = sum(rr_monthly) / n_distinct(yy))            

monthly_summary = as.data.frame(t(monthly_summary[, c(5,2,3,4)])) 
monthly_summary = round(monthly_summary, 1)
colnames(monthly_summary) = month.abb
print(monthly_summary)
JanFebMarAprMayJunJulAugSepOctNovDec
prec37.131.338.531.353.960.894.859.640.539.735.738.6
tmax8.711.217.223.828.331.632.331.826.921.314.39.8
tmin-15.0-11.9-7.6-3.31.05.88.97.52.7-2.4-5.2-10.4
tavg-1.00.53.79.414.417.419.419.014.39.14.50.8
# create plot with use of the "climatol" package:
climatol::diagwl(monthly_summary, mlab = "en", 
                 est = "POZNAŃ", alt = NA, 
                 per = "1991-2019", p3line = FALSE)

Walter and Lieth climatic diagram for Poznan, Poland

Example 6

Download monthly CO2 dataset from Mauna Loa observatory

library(climate)
library(ggplot2)
library(ggthemes)

co2 = meteo_noaa_co2()
head(co2)
co2$date = ISOdate(co2$yy, co2$mm, 1)
ggplot(co2, aes(date, co2_avg)) + 
  geom_line()+ geom_smooth()+
  theme_bw()+
  labs(
    title = "Carbon Dioxide (CO2)",
    subtitle = paste0("Mauna Loa Observatory "),
    caption = "data source: NOAA
    visualization: Bartosz Czernecki / R climate package",
    x = "",
    y = "ppm"
)

CO2 monthly concentration, Mauna Loa observatory

Example 7

Use "climate" inside python environment via rpy2

# load required packages
from rpy2.robjects.packages import importr
import rpy2.robjects as robjects
import pandas as pd
import datetime as dt

# load climate package (make sure that it was installed in R before)
importr("climate")
# test functionality e.g. with meteo_ogimet function for New York - La Guardia:
df = robjects.r["meteo_ogimet"](interval = "daily", station = 72503,
                                date = robjects.StrVector(["2022-05-01", "2022-06-15"]))
# optionally - transform object to pandas data frame and rename columns + fix datetime:
res = pd.DataFrame(df).transpose()
res.columns = df.colnames
res["Date"] = pd.TimedeltaIndex(res["Date"], unit="d") + dt.datetime(1970,1,1)
res.head

>>> res[res.columns[0:7]].head()
station_IDDateTemperatureCAvgTemperatureCMinTdAvgCHrAvg
72503.02022-06-1523.519.410.945.2
72503.02022-06-1425.020.616.159.0
72503.02022-06-1320.417.816.074.8
72503.02022-06-1221.318.312.057.1
72503.02022-06-1122.617.88.140.1

Example 8

Decode raw SYNOP messages with synop_parser()

The synop_parser() function decodes FM-12 SYNOP meteorological messages into structured R objects. For a detailed guide including all parameters and output formats, see the SYNOP Messages vignette.

library(climate)

synop_code = "AAXX 01004 88889 12782 61506 10094 20047 30111 40197 53007 60001 81541"

# Decode a single message — returns a named list
result = parser(synop_code)
result$station_id$value        #> "88889"
result$air_temperature$value   #> 9.4
result$wind_speed$value        #> 6
result$visibility$value        #> 40000
result$sea_level_pressure$value #> 1019.7
# Return a tidy data frame with one row per message
df = parser(synop_code, as_data_frame = TRUE)
df
station_typestation_idregionobs_dayobs_hourwind_unitwind_estimatedvisibilitycloud_coverwind_directionwind_speedair_temperaturedewpoint_temperature
AAXX88889III10KTFALSE40000615069.44.7
station_pressuresea_level_pressurepressure_tendencypressure_changeprecipitation_amountprecipitation_timecloud_base_mincloud_base_maxlow_cloud_typemiddle_cloud_typehigh_cloud_typelow_cloud_amountsource
1011.11019.70706150020005411AAXX 01004 88889 12782…
# Decode multiple SYNOP messages at once
msgs = c(
  "AAXX 01004 88889 12782 61506 10094 20047 30111 40197 53007 60001 81541",
  "AAXX 10124 26477 32560 83102 10156 20106 38528 40128 52003 60001 333 56017"
)
df2 = parser(msgs, as_data_frame = TRUE)
nrow(df2)       #> 2
df2$station_id  #> c("88889", "26477")
df2$source      # original SYNOP strings preserved in last column

Acknowledgment

Ogimet.com, University of Wyoming, and Institute of Meteorology and Water Management - National Research Institute (IMGW-PIB), National Oceanic & Atmospheric Administration (NOAA) - Earth System Research Laboratory, Global Monitoring Division and Integrated Surface Hourly (NOAA ISH) are the sources of the data.

Contribution

Contributions to this package are welcome. The preferred method of contribution is through a GitHub pull request. Feel also free to contact us by creating an issue.

Citation

To cite the climate package in publications, please use this paper:

Czernecki, B.; Głogowski, A.; Nowosad, J. Climate: An R Package to Access Free In-Situ Meteorological and Hydrological Datasets for Environmental Assessment. Sustainability 2020, 12, 394. https://doi.org/10.3390/su12010394"

LaTeX/BibTeX version can be obtained with:

library(climate)
citation("climate")