View source: R/monitor_leaflet.R
monitor_leaflet | R Documentation |
This function creates interactive maps that will be displayed in RStudio's
'Viewer' tab. The slice
argument is used to collapse a
mts_monitor timeseries into a single value. If slice
is an
integer, that row index will be selected from the 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(
monitor,
slice = "max",
radius = 10,
opacity = 0.7,
maptype = "terrain",
extraVars = NULL,
jitter = 5e-04,
NAAQS = c("PM2.5_2024", "PM2.5"),
...
)
monitor |
mts_monitor object. |
slice |
Either a formatted time string, a time index, the name of a (potentially user defined) function used to collapse the time axis. |
radius |
radius of monitor circles |
opacity |
opacity of monitor circles |
maptype |
optional name of leaflet ProviderTiles to use, e.g. "terrain" |
extraVars |
Character vector of additional column names from |
jitter |
Amount to use to slightly adjust locations so that multiple
monitors at the same location can be seen. Use zero or |
NAAQS |
Version of NAAQS levels to use. See Note. |
... |
Additional arguments passed to |
The maptype
argument is mapped onto leaflet "ProviderTile" names.
Current map types include:
– "OpenStreetMap"
– "Esri.WorldImagery"
– "Esri.WorldTopoMap"
– "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.
Invisibly returns a leaflet map of class "leaflet".
On February 7, 2024, EPA strengthened the National Ambient Air Quality Standards for Particulate Matter (PM NAAQS) to protect millions of Americans from harmful and costly health impacts, such as heart attacks and premature death. Particle or soot pollution is one of the most dangerous forms of air pollution, and an extensive body of science links it to a range of serious and sometimes deadly illnesses. EPA is setting the level of the primary (health-based) annual PM2.5 standard at 9.0 micrograms per cubic meter to provide increased public health protection, consistent with the available health science. See PM NAAQS update.
## Not run:
library(AirMonitor)
# Fail gracefully if any resources are not available
try({
# Maximum AQI category at each site
monitor_loadLatest() %>%
monitor_filter(stateCode %in% CONUS) %>%
monitor_leaflet()
# Mean AQI category at each site
monitor_loadLatest() %>%
monitor_filter(stateCode %in% CONUS) %>%
monitor_leaflet(
slice = "mean"
)
# Mean AQI category at each site using the updated NAAQS
monitor_loadLatest() %>%
monitor_filter(stateCode %in% CONUS) %>%
monitor_leaflet(
slice = "mean",
NAAQS = "PM2.5_2024"
)
}, silent = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.