knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) old <- options(scipen = 999)
The goal of the climate R package is to automatize downloading of meteorological and hydrological data from publicly available repositories:
The climate package consists of ten main functions - three for meteorological data, one for hydrological data and six auxiliary functions and datasets:
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 Organizaton (WMO) framework after year 2000 should be accessible.
meteo_imgw() - Downloading hourly, daily, and monthly meteorological data from the SYNOP/CLIMATE/PRECIP stations available in the dane.imgw.pl collection.
It is a wrapper for meteo_monthly()
, meteo_daily()
, and meteo_hourly()
meteo_noaa_hourly() - Downloading hourly NOAA Integrated Surface Hourly (ISH) meteorological data - Some stations have > 100 years long history of observations
sounding_wyoming() - Downloading measurements of the vertical profile of atmosphere (aka rawinsonde data)
hydro_monthly()
, and hydro_daily()
Examples shows application of climate package with additional use of tools that help with processing the data to increase legible of downloaded data.
Finding a 50 nearest meteorological stations for a given coordinates in a given country(ies):
``` {r stations , eval=T, fig.width=7,fig.height=7, fig.fullwidth=TRUE} library(climate) ns = nearest_stations_ogimet(country = c("United Kingdom", "France"), point = c(-3, 50), no_of_stations = 50, add_map = TRUE)
``` {r stations-2, eval=T} if (is.data.frame(ns)) { knitr::kable(head(ns, 15)) }
Summary of stations available in Ogimet repository for a selected country:
``` {r stations-3, eval=T, fig.width=7, fig.height=7, fig.fullwidth=T} library(climate) PL = stations_ogimet(country = "Poland", add_map = TRUE)
if (is.data.frame(PL)) { knitr::kable(head(PL)) }
### Example 3 Downlading hourly meteorological data from Svalbard (Norway) for year 2016 using NOAA service ```r df = readRDS(system.file("extdata/vignettes/svalbard_noaa.rds", package = "climate"))
``` {r windrose,eval=F}
df = meteo_noaa_hourly(station = "010080-99999", year = 2016)
``` {r noaa-kable,eval=T} knitr::kable(head(df))
Downloading atmospheric vertical profile (sounding) for Łeba, PL station:
library(climate) data("profile_demo") df2 = profile_demo[[1]] colnames(df2)[c(1, 3:4)] = c("PRESS", "TEMP", "DEWPT") # changing column names
profile_demo <- sounding_wyoming(wmo_id = 12120, yy = 2000, mm = 3, dd = 23, hh = 0) df2 = profile_demo[[1]] colnames(df2)[c(1, 3:4)] = c("PRESS", "TEMP", "DEWPT") # changing column names
knitr::kable(head(df2, 10), caption = "Exemplary data frame of sounding preprocessing")
Preparing an annual summary of air temperature and precipitation using dplyr syntax for 10-years period (1991-2000)
df = readRDS(system.file("extdata/vignettes/leba_monthly.rds", package = "climate"))
library(climate) df = meteo_imgw(interval = "monthly", rank = "synop", year = 1991:2000, station = "ŁEBA") # please note that sometimes 2 names are used for the same station in different years
suppressMessages(library(dplyr)) df2 = dplyr::select(df, station:t2m_mean_mon, rr_monthly) monthly_summary = df2 %>% dplyr::group_by(mm) %>% dplyr::summarise(tmax = mean(tmax_abs, na.rm = TRUE), tmin = mean(tmin_abs, na.rm = TRUE), tavg = mean(t2m_mean_mon, na.rm = TRUE), precip = 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
knitr::kable(head(monthly_summary), caption = "Exemplary data frame of meteorological preprocessing.")
Calculate the mean maximum value of the flow on the stations in each year with dplyr's summarise()
, and spread data by year using tidyr's spread()
to get the annual means of maximum flow in the consecutive columns.
h = readRDS(system.file("extdata/vignettes/hydro_monthly.rds", package = "climate"))
library(climate) library(dplyr) library(tidyr) h = hydro_imgw(interval = "monthly", year = 2001:2002, coords = TRUE)
knitr::kable(head(h))
h2 = h %>% dplyr::filter(idex == 3) %>% dplyr::select(id, station, X, Y, hyy, Q) %>% dplyr::group_by(hyy, id, station, X, Y) %>% dplyr::summarise(annual_mean_Q = round(mean(Q, na.rm = TRUE), 1)) %>% tidyr::pivot_wider(names_from = hyy, values_from = annual_mean_Q) knitr::kable(head(h2))
knitr::kable(head(h2), caption = "Exemplary data frame of hydrological preprocesssing.")
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 Laboratories - Global Monitoring Laboratory, Global Monitoring Division and Integrated Surface Hourly (NOAA ISH) are the sources of the data.
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.
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 version can be obtained with:
library(climate) citation("climate")
options(old)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.