This function creates interactive maps that will be displayed in RStudio's 'Viewer' tab. The slice argument is used to collapse a ws_monitor timeseries into a single value. If slice is an integer, that row index will be selected from the ws_monitor$data dataframe. If slice is a function (unquoted), that function will be applied to the timeseries with the argument na.rm=TRUE (e.g. max(..., na.rm=TRUE)).

If slice is a user defined function it will be used with argument na.rm=TRUE to collapse the time dimension. Thus, user defined functions must accept na.rm as an argument.

monitor_leaflet(
  ws_monitor,
  slice = get("max"),
  breaks = AQI$breaks_24,
  colors = AQI$colors,
  labels = AQI$names,
  legendTitle = "Max AQI Level",
  radius = 10,
  opacity = 0.7,
  maptype = "terrain",
  popupInfo = c("siteName", "monitorID", "elevation")
)

Arguments

ws_monitor

ws_monitor object

slice

either a time index or a function used to collapse the time axis -- defautls to get('max')

breaks

set of breaks used to assign colors

colors

a set of colors for different levels of air quality data determined by breaks

labels

a set of text labels, one for each color

legendTitle

legend title

radius

radius of monitor circles

opacity

opacity of monitor circles

maptype

optional name of leaflet ProviderTiles to use, e.g. "terrain"

popupInfo

a vector of column names from ws_monitor$meta to be shown in a popup window

Value

Invisbly returns a leaflet map of class "leaflet".

Details

The maptype argument is mapped onto leaflet "ProviderTile" names. Current mappings include:

  1. "roadmap" -- "OpenStreetMap"

  2. "satellite" -- "Esri.WorldImagery"

  3. "terrain" -- "Esri.WorldTopoMap"

  4. "toner" -- "Stamen.Toner"

If a character string not listed above is provided, it will be used as the underlying map tile if available. See https://leaflet-extras.github.io/leaflet-providers/ for a list of "provider tiles" to use as the background map.

Examples

if (FALSE) { # Fail gracefully if any resources are not available try({ # Napa Fires -- October, 2017 ca <- airnow_load(2017) %>% monitor_subset(tlim = c(20171001,20171101), stateCodes = 'CA') v_low <- AQI$breaks_24[5] CA_very_unhealthy_monitors <- monitor_subset(ca, vlim = c(v_low, Inf)) monitor_leaflet(CA_very_unhealthy_monitors, legendTitle = "October, 2017", maptype = "toner") }, silent = FALSE) }