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 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 danepubliczne.imgw.pl collection. It is a wrapper for meteo_monthly()
, meteo_daily()
, and meteo_hourly()
from the imgw package.
sounding_wyoming() - Downloading measurements of the vertical profile of atmosphere (aka rawinsonde data)
hydro_annual()
, hydro_monthly()
, and hydro_daily()
from the imgw package.Examples shows aplication 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 in a given country:
library(climate)
ns = nearest_stations_ogimet(country ="United+Kingdom",point = c(-4, 56),
no_of_stations = 50, add_map = TRUE)
head(ns)
#> wmo_id station_names lon lat alt distance [km]
#> 29 03144 Strathallan -3.733348 56.31667 35 46.44794
#> 32 03155 Drumalbin -3.733348 55.61668 245 52.38975
#> 30 03148 Glen Ogle -4.316673 56.41667 564 58.71862
#> 27 03134 Glasgow Bishopton -4.533344 55.90002 59 60.88179
#> 35 03166 Edinburgh Gogarbank -3.350007 55.93335 57 73.30942
#> 28 03136 Prestwick RNAS -4.583345 55.51668 26 84.99537
#> wmo_id station_names lon lat alt distance [km]
#> 29 03144 Strathallan -3.733348 56.31667 35 46.44794
#> 32 03155 Drumalbin -3.733348 55.61668 245 52.38975
#> 30 03148 Glen Ogle -4.316673 56.41667 564 58.71862
#> 27 03134 Glasgow Bishopton -4.533344 55.90002 59 60.88179
#> 35 03166 Edinburgh Gogarbank -3.350007 55.93335 57 73.30942
#> 28 03136 Prestwick RNAS -4.583345 55.51668 26 84.99537
Summary of stations availible in Ogimet repositoy selected by county:
Downlading hourly meteorological data Svalbard in 2018
# downloading data
df <- meteo_ogimet(interval = "hourly", date = c("2018-01-01", "2018-12-31"),station = c("01008"))
#> [1] "01008"
#>
|
| | 0%
|
|===== | 8%
|
|=========== | 17%
|
|================ | 25%
|
|====================== | 33%
|
|=========================== | 42%
|
|================================ | 50%
|
|====================================== | 58%
|
|=========================================== | 67%
|
|================================================= | 75%
|
|====================================================== | 83%
|
|============================================================ | 92%
|
|=================================================================| 100%
station_ID | Date | TC | TdC | TmaxC | TminC | ddd | ffkmh | Gustkmh | P0hPa | PseahPa | PTnd | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 1008 | 2018-12-31 23:00:00 | -14.3 | -19.2 | NA | NA | NNW | 25.2 | 43.2 | 1000.5 | 1004.2 | 0.3 |
3 | 1008 | 2018-12-31 22:00:00 | -13.7 | -18.2 | NA | NA | NW | 21.6 | 32.4 | 1000.0 | 1003.8 | -0.4 |
4 | 1008 | 2018-12-31 21:00:00 | -15.9 | -18.5 | NA | NA | ESE | 10.8 | 21.6 | 999.9 | 1003.7 | -0.6 |
5 | 1008 | 2018-12-31 20:00:00 | -16.8 | -20.1 | NA | NA | E | 18.0 | 25.2 | 1000.1 | 1003.9 | -0.9 |
6 | 1008 | 2018-12-31 19:00:00 | -17.2 | -21.7 | NA | NA | ESE | 21.6 | 28.8 | 1000.5 | 1004.3 | -1.3 |
7 | 1008 | 2018-12-31 18:00:00 | -18.3 | -20.8 | -15.5 | -19.5 | ESE | 21.6 | 32.4 | 1000.7 | 1004.5 | -1.9 |
8 | 1008 | 2018-12-31 17:00:00 | -18.1 | -23.1 | NA | NA | ESE | 25.2 | 32.4 | 1001.2 | 1005.0 | -1.9 |
9 | 1008 | 2018-12-31 16:00:00 | -18.1 | -22.6 | NA | NA | E | 21.6 | 25.2 | 1001.9 | 1005.7 | -1.6 |
10 | 1008 | 2018-12-31 15:00:00 | -19.2 | -24.1 | NA | NA | ESE | 21.6 | 25.2 | 1002.6 | 1006.5 | -1.2 |
11 | 1008 | 2018-12-31 14:00:00 | -18.9 | -24.7 | NA | NA | ESE | 18.0 | 25.2 | 1003.2 | 1007.0 | -0.7 |
Downloading sounding data for Łeba (Poland) station
library(climate)
profile <- sounding_wyoming(wmo_id = 12120, yy = 2020, mm = 3, dd = 23, hh = 0)
df2 <- profile[[1]]
colnames(df2)[c(1, 3:4)] = c("press", "temp", "dewpt") # changing column names
press | HGHT | temp | dewpt | RELH | MIXR | DRCT | SKNT | THTA | THTE | THTV |
---|---|---|---|---|---|---|---|---|---|---|
1042 | 6 | 0.4 | -6.6 | 59 | 2.25 | 70 | 2 | 270.4 | 276.6 | 270.7 |
1036 | 51 | 1.8 | -8.2 | 47 | 2.00 | 71 | 3 | 272.2 | 277.9 | 272.5 |
1000 | 328 | -0.7 | -10.7 | 47 | 1.70 | 80 | 10 | 272.4 | 277.3 | 272.7 |
925 | 944 | -6.7 | -11.1 | 71 | 1.78 | 65 | 12 | 272.4 | 277.5 | 272.8 |
921 | 977 | -7.0 | -11.2 | 72 | 1.77 | 65 | 12 | 272.5 | 277.5 | 272.8 |
874 | 1381 | -10.9 | -12.3 | 89 | 1.71 | 80 | 12 | 272.6 | 277.5 | 272.9 |
850 | 1596 | -12.9 | -12.9 | 100 | 1.68 | 55 | 12 | 272.6 | 277.4 | 272.9 |
849 | 1605 | -13.0 | -13.0 | 100 | 1.67 | 55 | 12 | 272.6 | 277.4 | 272.9 |
832 | 1759 | -14.2 | -14.3 | 99 | 1.52 | 75 | 14 | 272.9 | 277.3 | 273.2 |
820 | 1869 | -15.1 | -15.3 | 98 | 1.43 | 66 | 17 | 273.1 | 277.2 | 273.3 |
Preparing a annual summary of air temperature and precipitation, processing with dplyr
library(climate)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
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),
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
Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
precip | 37.0 | 30.9 | 38.2 | 30.5 | 54.5 | 60.2 | 93.2 | 60.7 | 42.3 | 38.0 | 35.6 | 38.6 |
tmax | 8.6 | 11.1 | 17.3 | 23.8 | 28.2 | 31.5 | 32.3 | 31.8 | 26.7 | 21.4 | 14.4 | 9.7 |
tmin | -15.0 | -12.2 | -7.8 | -3.3 | 0.9 | 5.6 | 8.9 | 7.4 | 2.7 | -2.5 | -5.2 | -10.6 |
tavg | -1.0 | 0.3 | 3.7 | 9.4 | 14.3 | 17.3 | 19.4 | 19.0 | 14.2 | 9.2 | 4.6 | 0.8 |
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.
library(climate)
library(dplyr)
library(tidyr)
h = hydro_imgw(interval = "monthly", year = 2001:2010, coords = TRUE)
head(h)
#> id X Y station riv_or_lake hyy idhyy idex H
#> 95158 150210180 21.8335 50.88641 ANNOPOL Wisła (2) 2001 1 1 214
#> 95159 150210180 21.8335 50.88641 ANNOPOL Wisła (2) 2001 1 2 228
#> 95160 150210180 21.8335 50.88641 ANNOPOL Wisła (2) 2001 1 3 250
#> 95161 150210180 21.8335 50.88641 ANNOPOL Wisła (2) 2001 2 1 215
#> 95162 150210180 21.8335 50.88641 ANNOPOL Wisła (2) 2001 2 2 225
#> 95163 150210180 21.8335 50.88641 ANNOPOL Wisła (2) 2001 2 3 258
#> Q T mm
#> 95158 172 NA 11
#> 95159 207 NA 11
#> 95160 272 NA 11
#> 95161 174 NA 12
#> 95162 201 NA 12
#> 95163 297 NA 12
h2 = h %>%
filter(idex == 3) %>%
select(id, station, X, Y, hyy, Q) %>%
group_by(hyy, id, station, X, Y) %>%
summarise(annual_mean_Q = round(mean(Q, na.rm = TRUE), 1)) %>%
pivot_wider(names_from = hyy, values_from = annual_mean_Q)
id | station | X | Y | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
149180010 | KRZYŻANOWICE | 18.28780 | 49.99301 | 200.5 | 147.4 | 87.9 | 109.2 | 170.6 | 226.9 | 152.9 | 131.0 | 160.9 | 461.1 |
149180020 | CHAŁUPKI | 18.32752 | 49.92127 | 174.7 | 96.7 | 57.6 | 91.8 | 146.9 | 170.6 | 110.2 | 101.6 | 124.7 | 314.6 |
149180040 | GOŁKOWICE | 18.49640 | 49.92579 | 4.5 | 2.0 | 1.7 | 1.7 | 2.5 | 3.3 | 2.1 | 1.7 | 2.2 | 8.6 |
149180050 | ZEBRZYDOWICE | 18.61326 | 49.88025 | 13.5 | 7.9 | 3.8 | 5.0 | 10.4 | 6.5 | 5.8 | 2.8 | 4.5 | 23.6 |
149180060 | CIESZYN | 18.62972 | 49.74616 | 57.2 | 57.7 | 29.8 | 26.8 | 65.4 | 60.7 | 54.7 | 33.0 | 34.7 | 135.0 |
149180070 | CIESZYN | 18.63137 | 49.74629 | NaN | NaN | NaN | NaN | NaN | NaN | 0.6 | 0.5 | 0.6 | 0.6 |
Ogimet.com, University of Wyoming, and Institute of Meteorology and Water Management - National Research Institute (IMGW-PIB) 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")