Project Description

Current project features a static markdown report that is updated every ten minutes and rendered into a HTML file. The reports shows the data completeness status of MeteoSwiss’ observation network (SwissMetNet). Data is made available through the opendata.swiss platform. A leaflet map provides an overview of current situtation, the colour scheme stands for the duration of the interruption. Customised map markers provide detailed information on the duration by type of sensor. A summary markdown table completes the report. Swisstopo map tiles have been be integrated into the Leaflet map.

Go to demo

Screenshot

Figure 1: Screenshot

Technology

  • MySQL DB
  • R packages: data.table, rmarkdown, leaflet, RMariaDB
  • Swisstopo map tiles

Code Snippets

Producing a simple leaflet map with markers is very easy in R. Current map contains customised popup windows with some HTML code (see figure 2). They are produced in function that takes station name, coordinates, parameter as arguments. It returns a character string containing the HTML code. The data.frame \(dt.map\) contains all the mapping information (longitude, latitude, meta data).

Example of a customised marker

Figure 2: Example of a customised marker

library(leaflet)
leaflet(dt.map, elementId = "mymap", 
  width = "100%", height = "600px") %>%
  addTiles("<url>/{z}/{x}/{y}.jpeg") %>%
  addCircleMarkers(~x, ~y, layerId = 1, group = "xxx", 
    fillColor = ~error.colours[type], popup = ~text, 
    label = ~name, color = "black", fillOpacity = .5, 
    stroke = T, weight = 1, radius = 9, 
    popupOptions = popupOptions(maxWidth = 500)
  )