Introduction to the imgw package (EN)

  collapse = TRUE,
  comment = "#>"

The main goal of the imgw package is to give convenient and programmable access to the Polish database of the archive meteorological and hydrological measurements.

It consists of tools that are:


The imgw package consists of nine main functions - four for meteorological data, four for hydrological data and one for sounding meteo:

  1. Meteorological data:

  2. meteo_hourly() - downloading meteorological the data with hourly interval

  3. meteo_daily() - downloading meteorological the data with daily interval
  4. meteo_monthly() - downloading meteorological the data with monthly interval
  5. meteo() - downloading meteorological the data with interval the user want to choose

  6. Hydrological data:

  7. hydro() - downloading hydrological the data with interval the user want to choose

  8. hydro_daily() - downloading hydrological the data with daily interval
  9. hydro_monthly() - downloading hyrological the data with monthly interval
  10. hydro_annual() - downloading hyrological the data with annual interval

  11. Rawinsonde data:

  12. meteo_sounding() -- downloading rawinsonde data (+metadata)

Most of the functions mentioned above have similar arguments allowing to choose:


imgw also has a few additional databases:

abbev = meteo_abbrev
station = meteo_stations


We will show how to use our package and prepare the data for spatial analysis with the additional help of the dplyr and tidyr packages. Firstly, we download ten years (2001-2010) of monthly hydrological observations for all stations available and automatically add their spatial coordinates.

h = hydro_monthly(year = 2001:2010, coords = TRUE)

The idex variable represents id of the extremum, where 1 means minimum, 2 mean, and 3 maximum.^[You can find more information about this in the hydro_abbrev dataset.] Hydrologists often use the maximum value so we will filter the data and select only the station id, hydrological year (hyy), latitude X and longitude Y. Next, we will 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.

h2 = h %>%
  filter(idex == 3) %>%
  select(id, station, X, Y, hyy, Q) %>%
  group_by(hyy, id, station, X, Y) %>%
  summarise(srednie_roczne_Q = round(mean(Q, na.rm = TRUE),1)) %>% 
  spread(hyy, srednie_roczne_Q)
kable(head(h2), caption = "Examplary data frame of hydrological preprocesssing.")

The result represent changing annual maximum average of water flow rate over the decade for all available stations in Poland. We can save it to:

world = ne_countries(scale = "medium", returnclass = "sf")

h3 = h2 %>% 
  filter(! %>% 
  st_as_sf(coords = c("X", "Y"))

tm_shape(h3) + 
  tm_symbols(size = as.character(c(2001:2010)),
             title.size = "Średni przepływ maksymalny") +
  tm_facets(free.scales = FALSE, ncol = 4) + 
  tm_shape(world) + 
  tm_borders(col = "black", lwd = 2) +
  tm_layout(legend.position = c(-1.25, 0.05),
            outer.margins = c(0, 0.05, 0, -0.25),
            panel.labels = as.character(c(2001:2010)))

Try the imgw package in your browser

Any scripts or data that you put into this service are public.

imgw documentation built on March 26, 2020, 7:37 p.m.