fmir provides simple tools for easily accessing up to date, open weather data from Finland. The data are made available by the Finnish Meteorological Institute and are licensed under CC-BY 4.0. See FMI’s open data manual for details.
Key features in fmir include:
FMI provides varying types of data in several different formats in their API, implemented using OGC Web Feature Service (WFS). Currently the only format supported by fmir is the “simple” weather format. For a more comprehensive and feature-rich package for accessing the FMI API, check out https://github.com/rOpenGov/fmi.
To start with, load the package:
We can construct queries to the API with fmi_query()
, and then execute them with fmi_data()
. A simple query with only a place
parameter will return weather observations with a 10-minute interval for the past 12 hours:
# generate a (vector of) query url(s)
q <- fmi_query(place = c("Espoo", "Oulu", "Rovaniemi"))
# download the data corresponding to the query
weather <- fmi_data(q)
weather
#> # A tibble: 216 x 14
#> place location time p_sea r_1h rh ri_10min snow_aws
#> <chr> <chr> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Espoo 60.1780~ 2019-02-09 22:50:00 995. NaN 93 0.5 39
#> 2 Espoo 60.1780~ 2019-02-09 23:00:00 995. 0.6 94 0.7 39
#> 3 Espoo 60.1780~ 2019-02-09 23:10:00 995. NaN 94 0.6 39
#> 4 Espoo 60.1780~ 2019-02-09 23:20:00 995. NaN 95 0.4 39
#> 5 Espoo 60.1780~ 2019-02-09 23:30:00 995. NaN 95 0.7 39
#> 6 Espoo 60.1780~ 2019-02-09 23:40:00 995 NaN 96 0.8 39
#> 7 Espoo 60.1780~ 2019-02-09 23:50:00 995 NaN 96 1.4 39
#> 8 Espoo 60.1780~ 2019-02-10 00:00:00 995. 0.9 97 1.6 39
#> 9 Espoo 60.1780~ 2019-02-10 00:10:00 995. NaN 97 1.2 39
#> 10 Espoo 60.1780~ 2019-02-10 00:20:00 995. NaN 97 1 39
#> # ... with 206 more rows, and 6 more variables: t2m <dbl>, td <dbl>,
#> # vis <dbl>, wd_10min <dbl>, wg_10min <dbl>, ws_10min <dbl>
Having the data at hand, we can then use ggplot2 to draw a simple line graph of the recent temperatures in Espoo, Oulu and Rovaniemi:
library(ggplot2)
# draw a simple line graph of the recent temperature
ggplot(weather, aes(time, t2m)) + geom_line(aes(colour = place))