knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

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.

Installation

The first step is to install fmir from github with devtools:

# install.packages("devtools")
devtools::install_github("mikmart/fmir")

Usage

To start with, load the package:

library(fmir)

A basic query

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

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))


mikmart/fmir documentation built on Feb. 28, 2021, 6:53 p.m.