Title: | Create Maps of Air Pollution Data |
---|---|
Description: | Combine the air quality data analysis methods of 'openair' with the JavaScript 'Leaflet' (<https://leafletjs.com/>) library. Functionality includes plotting site maps, "directional analysis" figures such as polar plots, and air mass trajectories. |
Authors: | Jack Davison [cre, aut] , David Carslaw [aut] |
Maintainer: | Jack Davison <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.9.1.9006 |
Built: | 2025-01-13 10:24:17 UTC |
Source: | https://github.com/openair-project/openairmaps |
This function is similar (but not identical to) the leaflet::addMarkers()
and leaflet::addCircleMarkers()
functions in leaflet
, which allows users
to add openair
directional analysis plots to any leaflet map and have more
control over groups and layerIds than in "all-in-one" functions like
polarMap()
.
addPolarMarkers( map, pollutant, fun = openair::polarPlot, lng = NULL, lat = NULL, layerId = NULL, group = NULL, popup = NULL, popupOptions = NULL, label = NULL, labelOptions = NULL, options = leaflet::markerOptions(), clusterOptions = NULL, clusterId = NULL, key = FALSE, d.icon = 200, d.fig = 3.5, data = leaflet::getMapData(map), ... ) addPolarDiffMarkers( map, pollutant, before = leaflet::getMapData(map), after = leaflet::getMapData(map), lng = NULL, lat = NULL, layerId = NULL, group = NULL, popup = NULL, popupOptions = NULL, label = NULL, labelOptions = NULL, options = leaflet::markerOptions(), clusterOptions = NULL, clusterId = NULL, key = FALSE, d.icon = 200, d.fig = 3.5, ... )
addPolarMarkers( map, pollutant, fun = openair::polarPlot, lng = NULL, lat = NULL, layerId = NULL, group = NULL, popup = NULL, popupOptions = NULL, label = NULL, labelOptions = NULL, options = leaflet::markerOptions(), clusterOptions = NULL, clusterId = NULL, key = FALSE, d.icon = 200, d.fig = 3.5, data = leaflet::getMapData(map), ... ) addPolarDiffMarkers( map, pollutant, before = leaflet::getMapData(map), after = leaflet::getMapData(map), lng = NULL, lat = NULL, layerId = NULL, group = NULL, popup = NULL, popupOptions = NULL, label = NULL, labelOptions = NULL, options = leaflet::markerOptions(), clusterOptions = NULL, clusterId = NULL, key = FALSE, d.icon = 200, d.fig = 3.5, ... )
map |
a map widget object created from |
pollutant |
The name of the pollutant to be plot. Note that, if |
fun |
An |
lng |
The decimal longitude. |
lat |
The decimal latitude. |
layerId |
the layer id |
group |
the name of the group the newly created layers should belong to
(for |
popup |
A column of |
popupOptions |
A Vector of |
label |
A column of |
labelOptions |
A Vector of |
options |
a list of extra options for tile layers, popups, paths (circles, rectangles, polygons, ...), or other map elements |
clusterOptions |
if not |
clusterId |
the id for the marker cluster layer |
key |
Should a key for each marker be drawn? Default is |
d.icon |
The diameter of the plot on the map in pixels. This will affect
the size of the individual polar markers. Alternatively, a vector in the
form |
d.fig |
The diameter of the plots to be produced using |
data |
A data frame. The data frame must contain the data to plot your
choice of openair directional analysis plot, which includes wind speed
( |
... |
Other arguments for the plotting function (e.g. |
before , after
|
A data frame that represents the before/after case. See
|
A leaflet object.
addPolarMarkers()
: Add any one-table polar marker (e.g.,
openair::polarPlot()
)
addPolarDiffMarkers()
: Add the two-table openair::polarDiff()
marker.
shiny::runExample(package = "openairmaps")
to see examples of this
function used in a shiny::shinyApp()
## Not run: library(leaflet) library(openair) # different types of polar plot on one map leaflet(data = polar_data) %>% addTiles() %>% addPolarMarkers("ws", fun = openair::windRose, group = "Wind Rose" ) %>% addPolarMarkers("nox", fun = openair::polarPlot, group = "Polar Plot" ) %>% addLayersControl( baseGroups = c("Wind Rose", "Polar Plot") ) # use of polar diff (NB: both 'before' and 'after' inherit from `leaflet()`, # so at least one should be overridden - in this case 'after') leaflet(data = polar_data) %>% addTiles() %>% addPolarDiffMarkers("nox", after = dplyr::mutate(polar_data, nox = jitter(nox, 5)) ) ## End(Not run)
## Not run: library(leaflet) library(openair) # different types of polar plot on one map leaflet(data = polar_data) %>% addTiles() %>% addPolarMarkers("ws", fun = openair::windRose, group = "Wind Rose" ) %>% addPolarMarkers("nox", fun = openair::polarPlot, group = "Polar Plot" ) %>% addLayersControl( baseGroups = c("Wind Rose", "Polar Plot") ) # use of polar diff (NB: both 'before' and 'after' inherit from `leaflet()`, # so at least one should be overridden - in this case 'after') leaflet(data = polar_data) %>% addTiles() %>% addPolarDiffMarkers("nox", after = dplyr::mutate(polar_data, nox = jitter(nox, 5)) ) ## End(Not run)
This function is similar (but not identical to) the leaflet::addMarkers()
function in leaflet
, which allows users to add trajectory paths to any
leaflet map and have more control over groups and layerIds than in
"all-in-one" functions like trajMap()
.
addTrajPaths( map, lng = "lon", lat = "lat", layerId = NULL, group = NULL, data = leaflet::getMapData(map), npoints = 12, ... )
addTrajPaths( map, lng = "lon", lat = "lat", layerId = NULL, group = NULL, data = leaflet::getMapData(map), npoints = 12, ... )
map |
a map widget object created from |
lng |
The decimal longitude. |
lat |
The decimal latitude. |
layerId |
The base string for the layer id. The actual layer IDs will be in the format "layerId-linenum" for lines and "layerId_linenum-pointnum" for points. For example, the first point of the first trajectory path will be "layerId-1-1". |
group |
the name of the group the newly created layers should belong to
(for |
data |
Data frame, the result of importing a trajectory file using
|
npoints |
A dot is placed every |
... |
Other arguments to pass to both |
addTrajPaths()
can be a powerful way of quickly plotting
trajectories on a leaflet map, but users should take some care due to any
additional arguments being passed to both leaflet::addCircleMarkers()
and
leaflet::addPolylines()
. In particular, users should be weary of the use
of the color
argument. Specifically, if color
is passed a vector of
length greater than one, multiple polylines will be drawn on top of one
another. At best this will affect opacity, but at worst this will
significantly impact the performance of R and the final leaflet map.
To mitigate this, please ensure that any vector passed to color
is of
length one. This is simple if you want the whole path to be the same
colour, but more difficult if you want to colour by a pollutant, for
example. The easiest way to achieve this is to write a for loop or use
another iterative approach (e.g. the purrr
package) to add one path per
arrival date. An example of this is provided in the Examples.
A leaflet object.
shiny::runExample(package = "openairmaps")
to see examples of this
function used in a shiny::shinyApp()
## Not run: library(leaflet) library(openairmaps) pal <- colorNumeric(palette = "viridis", domain = traj_data$nox) map <- leaflet() %>% addTiles() for (i in seq(length(unique(traj_data$date)))) { data <- dplyr::filter(traj_data, date == unique(traj_data$date)[i]) map <- map %>% addTrajPaths( data = data, color = pal(data$nox)[1] ) } map ## End(Not run)
## Not run: library(leaflet) library(openairmaps) pal <- colorNumeric(palette = "viridis", domain = traj_data$nox) map <- leaflet() %>% addTiles() for (i in seq(length(unique(traj_data$date)))) { data <- dplyr::filter(traj_data, date == unique(traj_data$date)[i]) map <- map %>% addTrajPaths( data = data, color = pal(data$nox)[1] ) } map ## End(Not run)
The annulusMap()
function creates a map using polar annulus plots as
markers. Any number of pollutants can be specified using the pollutant
argument, and multiple layers of markers can be created using type
. By
default, these maps are dynamic and can be panned, zoomed, and otherwise
interacted with. Using the static
argument allows for static images to be
produced instead.
annulusMap( data, pollutant = NULL, period = "hour", limits = "free", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
annulusMap( data, pollutant = NULL, period = "hour", limits = "free", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
data |
Input data table with pollutant, wind, and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
pollutant |
Pollutant name(s). required | scope: dynamic & static The column name(s) of the pollutant(s) to plot. If multiple pollutants are
specified and a non-pairwise statistic is supplied, the
Multiple |
period |
Temporal period for radial axis. default: Options are "hour" (the default, to plot diurnal variations), "season" to plot variation throughout the year, "weekday" to plot day of the week variation and "trend" to plot the trend by wind direction. |
limits |
Specifier for the plot colour scale bounds. default: One of:
|
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
diffMap()
,
freqMap()
,
percentileMap()
,
polarMap()
,
pollroseMap()
,
windroseMap()
## Not run: annulusMap(polar_data, pollutant = "nox", period = "hour", provider = "CartoDB.Voyager" ) ## End(Not run)
## Not run: annulusMap(polar_data, pollutant = "nox", period = "hour", provider = "CartoDB.Voyager" ) ## End(Not run)
Group a dataframe together by latitude/longitude columns and create a HTML
popup with user-defined columns. By default, the unique values of character
columns are collapsed into comma-separated lists, numeric columns are
averaged, and date columns are presented as a range. This function returns
the input dataframe appended with a "popup" column, which can then be used in
the popup
argument of a function like polarMap()
.
buildPopup( data, columns, latitude = NULL, longitude = NULL, type = NULL, fun.character = function(x) paste(unique(x), collapse = ", "), fun.numeric = function(x) signif(mean(x, na.rm = TRUE), 3), fun.dttm = function(x) paste(lubridate::floor_date(range(x, na.rm = TRUE), "day"), collapse = " to "), ... )
buildPopup( data, columns, latitude = NULL, longitude = NULL, type = NULL, fun.character = function(x) paste(unique(x), collapse = ", "), fun.numeric = function(x) signif(mean(x, na.rm = TRUE), 3), fun.dttm = function(x) paste(lubridate::floor_date(range(x, na.rm = TRUE), "day"), collapse = " to "), ... )
data |
Input data table with geo-spatial information. required A data frame containing latitude and longitude information that will go on
to be used in a function such as |
columns |
A character vector of column names to include in the popup. required Summaries of the selected columns will appear in the popup. If a named vector is provided, the names of the vector will be used in place of the raw column names. See the Examples for more information. |
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
type |
A column to be passed to the default: Column which will be used for the |
fun.character |
A function to summarise character and factor columns. default: The default collapses unique values into a comma-separated list. |
fun.numeric |
A function to summarise numeric columns. default: The default takes the mean to three significant figures. Other numeric summaries may be of interest, such as the maximum, minimum, standard deviation, and so on. |
fun.dttm |
A function to summarise date columns. default: The default presents the date as a range. Other statistics of interest could be the start or end of the dates. |
... |
Not currently used. |
a tibble
## Not run: buildPopup( data = polar_data, columns = c( "Site" = "site", "Site Type" = "site_type", "Date Range" = "date" ) ) %>% polarMap("nox", popup = "popup") ## End(Not run)
## Not run: buildPopup( data = polar_data, columns = c( "Site" = "site", "Site Type" = "site_type", "Date Range" = "date" ) ) %>% polarMap("nox", popup = "popup") ## End(Not run)
This is a much simpler implementation of the tools found in the
PostcodesioR
R package, intended for use with the searchNetwork()
function.
convertPostcode(postcode)
convertPostcode(postcode)
postcode |
A valid UK postcode. required A string containing a single valid UK postcode, e.g., |
A list containing the latitude, longitude, and input postcode.
The PostcodesioR
package at
https://github.com/ropensci/PostcodesioR/
# convert a UK postcode convertPostcode("SW1A1AA") ## Not run: # use with `searchNetwork()` palace <- convertPostcode("SW1A1AA") searchNetwork(lat = palace$lat, lng = palace$lng, max_dist = 10) ## End(Not run)
# convert a UK postcode convertPostcode("SW1A1AA") ## Not run: # use with `searchNetwork()` palace <- convertPostcode("SW1A1AA") searchNetwork(lat = palace$lat, lng = palace$lng, max_dist = 10) ## End(Not run)
The diffMap()
function creates a map using bivariate polar plots as
markers. Any number of pollutants can be specified using the pollutant
argument, and multiple layers of markers can be created using type
. By
default, these maps are dynamic and can be panned, zoomed, and otherwise
interacted with. Using the static
argument allows for static images to be
produced instead.
diffMap( before, after, pollutant = NULL, x = "ws", limits = "free", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = rev(openair::openColours("RdBu", 10)), alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
diffMap( before, after, pollutant = NULL, x = "ws", limits = "free", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = rev(openair::openColours("RdBu", 10)), alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
before |
A data frame that represents the "before" case. See
|
after |
A data frame that represents the "after" case. See |
pollutant |
Mandatory. A pollutant name corresponding to a variable in a
data frame should be supplied e.g. |
x |
Name of variable to plot against wind direction in polar coordinates, the default is wind speed, “ws”. |
limits |
Limits for the plot colour scale. default: One of:
Note that the |
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
annulusMap()
,
freqMap()
,
percentileMap()
,
polarMap()
,
pollroseMap()
,
windroseMap()
## Not run: # NB: "after" is some dummy data to demonstrate functionality diffMap( before = polar_data, after = dplyr::mutate(polar_data, nox = jitter(nox, factor = 5)), pollutant = "nox" ) ## End(Not run)
## Not run: # NB: "after" is some dummy data to demonstrate functionality diffMap( before = polar_data, after = dplyr::mutate(polar_data, nox = jitter(nox, factor = 5)), pollutant = "nox" ) ## End(Not run)
The freqMap()
function creates a map using polar frequency plots as
markers. Any number of pollutants can be specified using the pollutant
argument, and multiple layers of markers can be created using type
. By
default, these maps are dynamic and can be panned, zoomed, and otherwise
interacted with. Using the static
argument allows for static images to be
produced instead.
freqMap( data, pollutant = NULL, statistic = "mean", breaks = "free", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
freqMap( data, pollutant = NULL, statistic = "mean", breaks = "free", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
data |
Input data table with pollutant, wind, and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
pollutant |
Pollutant name(s). required | scope: dynamic & static The column name(s) of the pollutant(s) to plot. If multiple pollutants are
specified and a non-pairwise statistic is supplied, the
Multiple |
statistic |
The statistic that should be applied to each wind speed/direction bin. default: Can be "frequency", "mean", "median", "max" (maximum), "stdev" (standard
deviation) or "weighted.mean". The option "frequency" is the simplest and
plots the frequency of wind speed/direction in different bins. The scale
therefore shows the counts in each bin. The option "mean" (the default) will
plot the mean concentration of a pollutant (see next point) in wind
speed/direction bins, and so on. Finally, "weighted.mean" will plot the
concentration of a pollutant weighted by wind speed/direction. Each segment
therefore provides the percentage overall contribution to the total
concentration. Note that for options other than "frequency", it is necessary
to also provide the name of a pollutant. See function |
breaks |
Specifier for the breaks of the plot colour scale. default: One of:
|
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
annulusMap()
,
diffMap()
,
percentileMap()
,
polarMap()
,
pollroseMap()
,
windroseMap()
## Not run: freqMap(polar_data, pollutant = "nox", statistic = "mean", provider = "CartoDB.Voyager" ) ## End(Not run)
## Not run: freqMap(polar_data, pollutant = "nox", statistic = "mean", provider = "CartoDB.Voyager" ) ## End(Not run)
This function uses openair::importMeta()
to obtain metadata for measurement
sites and uses it to create an attractive leaflet
map. By default a map
will be created in which readers may toggle between a vector base map and a
satellite/aerial image, although users can further customise the control menu
using the provider
and control
parameters.
networkMap( source = "aurn", control = NULL, year = NULL, cluster = TRUE, provider = c(Default = "OpenStreetMap", Satellite = "Esri.WorldImagery"), legend = TRUE, legend.position = "topright", control.collapsed = FALSE, control.position = "topright" )
networkMap( source = "aurn", control = NULL, year = NULL, cluster = TRUE, provider = c(Default = "OpenStreetMap", Satellite = "Esri.WorldImagery"), legend = TRUE, legend.position = "topright", control.collapsed = FALSE, control.position = "topright" )
source |
One or more UK or European monitoring networks. default: One or more air quality networks for which data is available through openair. Available networks include:
There are two additional options provided for convenience:
|
control |
Option to create a 'layer control' menu. default: A string to specify categories in a "layer control" menu, to allow readers to select between different site categories. Choices include:
|
year |
A year, or range of years, with which to filter data. default: By default, |
cluster |
Cluster markers together when zoomed out? default: When |
provider |
The basemap(s) to be used. default: Any number of leaflet::providers. See
http://leaflet-extras.github.io/leaflet-providers/preview/ for a list of
all base maps that can be used. If multiple base maps are provided, they
can be toggled between using a "layer control" interface. By default, the
interface will use the provider names as labels, but users can define their
own using a named vector (e.g., |
legend |
Draw a shared legend? default: When multiple |
legend.position |
Position of the legend default: Where should the shared legend be placed? One of "topleft", "topright",
"bottomleft" or "bottomright". Passed to the |
control.collapsed |
Show the layer control as a collapsed? default: Should the "layer control" interface be collapsed? If |
control.position |
Position of the layer control menu default: Where should the "layer control" interface be placed? One of "topleft",
"topright", "bottomleft" or "bottomright". Passed to the |
When selecting multiple data sources using source
, please be mindful that
there can be overlap between the different networks. For example, an air
quality site in Scotland may be part of the AURN and the SAQN.
networkMap()
will only show one marker for such sites, and uses the order
in which source
arguments are provided as the hierarchy by which to assign
sites to networks. The aforementioned AURN & SAQN site will therefore have
its SAQN code displayed if source = c("saqn", "aurn")
, and its AURN code
displayed if source = c("aurn", "saqn")
.
This hierarchy is also reflected when control = "network"
is used. As
leaflet
markers cannot be part of multiple groups, the AURN & SAQN site
will be part of the "SAQN" layer control group when source = c("saqn", "aurn")
and the "AURN" layer control group when source = c("aurn", "saqn")
.
A leaflet object.
Other uk air quality network mapping functions:
searchNetwork()
## Not run: # view one network, grouped by site type networkMap(source = "aurn", control = "site_type") # view multiple networks, grouped by network networkMap(source = c("aurn", "waqn", "saqn"), control = "network") ## End(Not run)
## Not run: # view one network, grouped by site type networkMap(source = "aurn", control = "site_type") # view multiple networks, grouped by network networkMap(source = c("aurn", "waqn", "saqn"), control = "network") ## End(Not run)
The percentileMap()
function creates a map using polar percentile roses as
markers. Any number of pollutants can be specified using the pollutant
argument, and multiple layers of markers can be created using type
. By
default, these maps are dynamic and can be panned, zoomed, and otherwise
interacted with. Using the static
argument allows for static images to be
produced instead.
percentileMap( data, pollutant = NULL, percentile = c(25, 50, 75, 90, 95), intervals = "fixed", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
percentileMap( data, pollutant = NULL, percentile = c(25, 50, 75, 90, 95), intervals = "fixed", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
data |
Input data table with pollutant, wind, and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
pollutant |
Pollutant name(s). required | scope: dynamic & static The column name(s) of the pollutant(s) to plot. If multiple pollutants are
specified and a non-pairwise statistic is supplied, the
Multiple |
percentile |
The percentile values for the colour scale bin. default: The percentile value(s) to plot using |
intervals |
Specifier for the percentile rose radial axis intervals. default: One of:
|
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
annulusMap()
,
diffMap()
,
freqMap()
,
polarMap()
,
pollroseMap()
,
windroseMap()
## Not run: percentileMap(polar_data, pollutant = "nox", provider = "CartoDB.Voyager" ) ## End(Not run)
## Not run: percentileMap(polar_data, pollutant = "nox", provider = "CartoDB.Voyager" ) ## End(Not run)
The polar_data
dataset is provided as an example dataset as part of
the openairmaps
package. The dataset contains hourly measurements of
air pollutant concentrations, location and meteorological data.
Data frame with example data from four sites in London in 2009.
The date and time of the measurement
Pollutant concentrations
The site name. Useful for use with the popup
and label
arguments in openairmaps
functions.
Decimal latitude and longitude of the sites.
Site type of the site (either "Urban Traffic" or "Urban Background").
Wind direction, in degrees from North, as a numeric vector.
Wind speed, in m/s, as numeric vector.
The visibility in metres.
Air temperature in degrees Celcius.
polar_data
is supplied with the openairmaps
package as an
example dataset for use with documented examples.
polar_data
was compiled from data using the
openair::importAURN()
function from the openair
package with
meteorological data from the worldmet
package.
# basic structure head(polar_data)
# basic structure head(polar_data)
The polarMap()
function creates a map using bivariate polar plots as
markers. Any number of pollutants can be specified using the pollutant
argument, and multiple layers of markers can be created using type
. By
default, these maps are dynamic and can be panned, zoomed, and otherwise
interacted with. Using the static
argument allows for static images to be
produced instead.
polarMap( data, pollutant = NULL, x = "ws", limits = "free", upper = "fixed", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
polarMap( data, pollutant = NULL, x = "ws", limits = "free", upper = "fixed", latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
data |
Input data table with pollutant, wind, and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
pollutant |
Pollutant name(s). required | scope: dynamic & static The column name(s) of the pollutant(s) to plot. If multiple pollutants are
specified and a non-pairwise statistic is supplied, the
Multiple |
x |
The radial axis variable. default: The column name for the radial axis variable to use in
|
limits |
Specifier for the plot colour scale bounds. default: One of:
|
upper |
Specifier for the polar plot radial axis upper boundary. default: One of:
|
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
annulusMap()
,
diffMap()
,
freqMap()
,
percentileMap()
,
pollroseMap()
,
windroseMap()
## Not run: polarMap(polar_data, pollutant = "nox", x = "ws", provider = "CartoDB.Voyager" ) ## End(Not run)
## Not run: polarMap(polar_data, pollutant = "nox", x = "ws", provider = "CartoDB.Voyager" ) ## End(Not run)
Static direction analysis mapping functions have been deprecated in favour
of combined functions (e.g., polarMap()
), which present a more
consistent, unified API for users to simply swap between the two output
formats.
polarMapStatic( data, pollutant = NULL, x = "ws", limits = "free", upper = "fixed", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) diffMapStatic( before, after, pollutant = NULL, limits = "free", x = "ws", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = c("#002F70", "#3167BB", "#879FDB", "#C8D2F1", "#F6F6F6", "#F4C8C8", "#DA8A8B", "#AE4647", "#5F1415"), alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) annulusMapStatic( data, pollutant = NULL, period = "hour", facet = NULL, limits = "free", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) windroseMapStatic( data, ws.int = 2, breaks = 4, facet = NULL, latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) pollroseMapStatic( data, pollutant = NULL, statistic = "prop.count", breaks = NULL, facet = NULL, latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) percentileMapStatic( data, pollutant = NULL, percentile = c(25, 50, 75, 90, 95), intervals = "fixed", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) freqMapStatic( data, pollutant = NULL, statistic = "mean", breaks = "free", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... )
polarMapStatic( data, pollutant = NULL, x = "ws", limits = "free", upper = "fixed", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) diffMapStatic( before, after, pollutant = NULL, limits = "free", x = "ws", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = c("#002F70", "#3167BB", "#879FDB", "#C8D2F1", "#F6F6F6", "#F4C8C8", "#DA8A8B", "#AE4647", "#5F1415"), alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) annulusMapStatic( data, pollutant = NULL, period = "hour", facet = NULL, limits = "free", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) windroseMapStatic( data, ws.int = 2, breaks = 4, facet = NULL, latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) pollroseMapStatic( data, pollutant = NULL, statistic = "prop.count", breaks = NULL, facet = NULL, latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) percentileMapStatic( data, pollutant = NULL, percentile = c(25, 50, 75, 90, 95), intervals = "fixed", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... ) freqMapStatic( data, pollutant = NULL, statistic = "mean", breaks = "free", latitude = NULL, longitude = NULL, crs = 4326, provider = "osm", facet = NULL, cols = "turbo", alpha = 1, key = FALSE, facet.nrow = NULL, d.icon = 150, d.fig = 3, ... )
data |
Input data table with pollutant, wind, and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
pollutant |
Pollutant name(s). required | scope: dynamic & static The column name(s) of the pollutant(s) to plot. If multiple pollutants are
specified and a non-pairwise statistic is supplied, the
Multiple |
x |
The radial axis variable. default: The column name for the radial axis variable to use in
|
limits |
Specifier for the plot colour scale bounds. default: One of:
|
upper |
Specifier for the polar plot radial axis upper boundary. default: One of:
|
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
facet |
Passed to the |
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
facet.nrow |
Passed to the |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
... |
Passed to the polar plotting function |
before |
A data frame that represents the "before" case. See
|
after |
A data frame that represents the "after" case. See |
period |
Temporal period for radial axis. default: Options are "hour" (the default, to plot diurnal variations), "season" to plot variation throughout the year, "weekday" to plot day of the week variation and "trend" to plot the trend by wind direction. |
ws.int |
The wind speed interval of the colour axis. default: The wind speed interval. Default is 2 m/s but for low met masts with low mean wind speeds a value of 1 or 0.5 m/s may be better. |
breaks |
Specifier for the number of breaks of the colour axis. default: Most commonly, the number of break points for wind speed in
|
statistic |
The statistic to be applied to each data bin in the plot default: Options currently include |
percentile |
The percentile values for the colour scale bin. default: The percentile value(s) to plot using |
intervals |
Specifier for the percentile rose radial axis intervals. default: One of:
|
a ggplot2
object using ggplot2::coord_sf()
coordinates with a
ggspatial
basemap
The pollroseMap()
function creates a map using pollution roses as markers.
Any number of pollutants can be specified using the pollutant
argument, and
multiple layers of markers can be created using type
. By default, these
maps are dynamic and can be panned, zoomed, and otherwise interacted with.
Using the static
argument allows for static images to be produced instead.
pollroseMap( data, pollutant = NULL, statistic = "prop.count", breaks = NULL, latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
pollroseMap( data, pollutant = NULL, statistic = "prop.count", breaks = NULL, latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
data |
Input data table with pollutant, wind, and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
pollutant |
Pollutant name(s). required | scope: dynamic & static The column name(s) of the pollutant(s) to plot. If multiple pollutants are
specified and a non-pairwise statistic is supplied, the
Multiple |
statistic |
The statistic to be applied to each data bin in the plot default: Options currently include |
breaks |
Specifier for the number of breaks of the colour axis. default: Most commonly, the number of break points. If not specified, each marker
will independently break its supplied data at approximately 6 sensible
break points. When |
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
annulusMap()
,
diffMap()
,
freqMap()
,
percentileMap()
,
polarMap()
,
windroseMap()
## Not run: pollroseMap(polar_data, pollutant = "nox", statistic = "prop.count", provider = "CartoDB.Voyager" ) ## End(Not run)
## Not run: pollroseMap(polar_data, pollutant = "nox", statistic = "prop.count", provider = "CartoDB.Voyager" ) ## End(Not run)
openairmaps
Workhorse function that automatically applies routine text formatting to
common pollutant names which may be used in the HTML widgets produced by
openairmaps
.
quickTextHTML(text)
quickTextHTML(text)
text |
A character vector. required A character vector containing common pollutant names to be formatted. Commonly, this will insert super- and subscript HTML tags, e.g., "NO2" will be replaced with "NO2". |
quickTextHTML()
is routine formatting lookup table. It screens the supplied
character vector text
and automatically applies formatting to any
recognised character sub-series to properly render in HTML.
a character vector
Jack Davison.
openair::quickText()
, useful for non-HTML/static maps and plots
labs <- c("no2", "o3", "so2") quickTextHTML(labs)
labs <- c("no2", "o3", "so2") quickTextHTML(labs)
openair::importMeta()
While networkMap()
visualises entire UK air quality networks,
searchNetwork()
can subset specific networks to find air quality sites near
to a specific site of interest (for example, the location of known industrial
activity, or the centroid of a specific urban area).
searchNetwork( lat, lng, source = "aurn", year = NULL, site_type = NULL, variable = NULL, max_dist = NULL, n = NULL, crs = 4326, map = TRUE )
searchNetwork( lat, lng, source = "aurn", year = NULL, site_type = NULL, variable = NULL, max_dist = NULL, n = NULL, crs = 4326, map = TRUE )
lat , lng
|
The decimal latitude(Y)/longitude(X). required Values representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
source |
One or more UK or European monitoring networks. default: One or more air quality networks for which data is available through openair. Available networks include:
There are two additional options provided for convenience:
|
year |
A year, or range of years, with which to filter data. default: By default, |
site_type |
One or more site types with which to subset the site metadata. default: If |
variable |
One or more variables of interest with which to subset the site metadata. default: If |
max_dist |
A maximum distance from the location of interest in kilometres. default: If |
n |
The maximum number of sites to return. default: If |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
map |
Return a map? default: If |
Data subsetting progresses in the order in which the arguments are given;
first source
and year
, then site_type
and variable
, then max_dist
,
and finally n
.
Either a tibble or leaflet
map.
Other uk air quality network mapping functions:
networkMap()
## Not run: # get all AURN sites open in 2020 within 20 km of Buckingham Palace palace <- convertPostcode("SW1A1AA") searchNetwork(lat = palace$lat, lng = palace$lng, max_dist = 20, year = 2020) ## End(Not run)
## Not run: # get all AURN sites open in 2020 within 20 km of Buckingham Palace palace <- convertPostcode("SW1A1AA") searchNetwork(lat = palace$lat, lng = palace$lng, max_dist = 20, year = 2020) ## End(Not run)
The traj_data
dataset is provided as an example dataset as part of the
openairmaps
package. The dataset contains HYSPLIT back trajectory data for
air mass parcels arriving in London in 2009. It has been joined with air
quality pollutant concentrations from the "London N. Kensington" AURN urban
background monitoring site.
traj_data
traj_data
A data frame with 53940 rows and 10 variables:
The arrival time of the air-mass
The receptor number
Trajectory year
Trajectory month
Trajectory day
Trajectory hour
Trajectory hour offset from the arrival date
Latitude
Longitude
Height of trajectory in m
Pressure of the trajectory in Pa
Date of the trajectory
Concentration of oxides of nitrogen (NO + NO2)
Concentration of nitrogen dioxide (NO2)
Concentration of ozone (O3)
Concentration of particulates (PM10)
Concentration of fine particulates (PM2.5)
traj_data
is supplied with the openairmaps
package as an example dataset
for use with documented examples.
traj_data
was compiled from data using the openair::importTraj()
function from the openair
package with air quality data from
openair::importAURN()
function.
# basic structure head(traj_data)
# basic structure head(traj_data)
leaflet
This function plots back trajectories on a leaflet
map. This function
requires that data are imported using the openair::importTraj()
function.
trajLevelMap( data, longitude = "lon", latitude = "lat", pollutant, type = NULL, smooth = FALSE, statistic = "frequency", percentile = 90, lon.inc = 1, lat.inc = 1, min.bin = 1, .combine = NA, sigma = 1.5, cols = "turbo", alpha = 0.5, tile.border = NA, provider = "OpenStreetMap", legend.position = "topright", legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright" )
trajLevelMap( data, longitude = "lon", latitude = "lat", pollutant, type = NULL, smooth = FALSE, statistic = "frequency", percentile = 90, lon.inc = 1, lat.inc = 1, min.bin = 1, .combine = NA, sigma = 1.5, cols = "turbo", alpha = 0.5, tile.border = NA, provider = "OpenStreetMap", legend.position = "topright", legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright" )
data |
A data frame containing a HYSPLIT trajectory, perhaps accessed
with required A data frame containing HYSPLIT model outputs. If this data were not
obtained using |
latitude , longitude
|
The decimal latitude/longitude. default: Column names representing the decimal latitude and longitude. |
pollutant |
Pollutant to be plotted. By default the trajectory height is used. |
type |
A method to condition the default: Used for splitting the trajectories into different groups which can be
selected between using a "layer control" menu. Passed to
|
smooth |
Should the trajectory surface be smoothed? Defaults to |
statistic |
Statistic to use for There are also various ways of plotting concentrations. It is possible to set If If If |
percentile |
The percentile concentration of |
lon.inc , lat.inc
|
The longitude and latitude intervals to be used for binning data. |
min.bin |
The minimum number of unique points in a grid cell. Counts
below |
.combine |
When statistic is "SQTBA" it is possible to combine lots of
receptor locations to derive a single map. |
sigma |
For the SQTBA approach |
cols |
The colours used for plotting, passed to
|
alpha |
Opacity of the tiles. Must be between |
tile.border |
Colour to use for the border of binned tiles. Defaults to
|
provider |
The basemap to be used. default: A single leaflet::providers. See http://leaflet-extras.github.io/leaflet-providers/preview/ for a list of all base maps that can be used. |
legend.position |
Position of the shared legend. default: Where should the legend be placed? One of "topright", "topright",
"bottomleft" or "bottomright". Passed to the |
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: Should the "layer control" interface be collapsed? If |
control.position |
Position of the layer control menu default: Where should the "layer control" interface be placed? One of "topleft",
"topright", "bottomleft" or "bottomright". Passed to the |
A leaflet object.
trajLevelMapStatic()
for the static ggplot2
equivalent of
trajLevelMap()
Other interactive trajectory maps:
trajMap()
## Not run: trajLevelMap(traj_data, pollutant = "pm2.5", statistic = "pscf", min.bin = 10) ## End(Not run)
## Not run: trajLevelMap(traj_data, pollutant = "pm2.5", statistic = "pscf", min.bin = 10) ## End(Not run)
ggplot2
This function plots back trajectories on a ggplot2
map. This function
requires that data are imported using the openair::importTraj()
function.
It is a ggplot2
implementation of openair::trajLevel()
with many of the
same arguments, which should be more flexible for post-hoc changes.
trajLevelMapStatic( data, longitude = "lon", latitude = "lat", pollutant, type = NULL, smooth = FALSE, statistic = "frequency", percentile = 90, lon.inc = 1, lat.inc = 1, min.bin = 1, .combine = NA, sigma = 1.5, alpha = 0.5, tile.border = NA, xlim = NULL, ylim = NULL, crs = sf::st_crs(4326), map = TRUE, map.fill = "grey85", map.colour = "grey75", map.alpha = 0.8, map.lwd = 0.5, map.lty = 1, facet = NULL, ... )
trajLevelMapStatic( data, longitude = "lon", latitude = "lat", pollutant, type = NULL, smooth = FALSE, statistic = "frequency", percentile = 90, lon.inc = 1, lat.inc = 1, min.bin = 1, .combine = NA, sigma = 1.5, alpha = 0.5, tile.border = NA, xlim = NULL, ylim = NULL, crs = sf::st_crs(4326), map = TRUE, map.fill = "grey85", map.colour = "grey75", map.alpha = 0.8, map.lwd = 0.5, map.lty = 1, facet = NULL, ... )
data |
A data frame containing a HYSPLIT trajectory, perhaps accessed
with required A data frame containing HYSPLIT model outputs. If this data were not
obtained using |
latitude , longitude
|
The decimal latitude/longitude. default: Column names representing the decimal latitude and longitude. |
pollutant |
Pollutant to be plotted. By default the trajectory height is used. |
type |
A method to condition the default: Used for splitting the trajectories into different groups which can be
selected between using a "layer control" menu. Passed to
|
smooth |
Should the trajectory surface be smoothed? Defaults to |
statistic |
Statistic to use for There are also various ways of plotting concentrations. It is possible to set If If If |
percentile |
The percentile concentration of |
lon.inc , lat.inc
|
The longitude and latitude intervals to be used for binning data. |
min.bin |
The minimum number of unique points in a grid cell. Counts
below |
.combine |
When statistic is "SQTBA" it is possible to combine lots of
receptor locations to derive a single map. |
sigma |
For the SQTBA approach |
alpha |
Opacity of the tiles. Must be between |
tile.border |
Colour to use for the border of binned tiles. Defaults to
|
xlim , ylim
|
The x- and y-limits of the plot. default: A numeric vector of length two defining the x-/y-limits of the map, passed
to |
crs |
The coordinate reference system (CRS) into which all data should
be projected before plotting. Defaults to latitude/longitude
( |
map |
Draw a base map? default: Draws the geometries of countries under the trajectory paths. |
map.fill |
Colour to use to fill the polygons of the base map. default: See |
map.colour |
Colour to use for the polygon borders of the base map. default: See |
map.alpha |
Transparency of the base map polygons. default: Must be between |
map.lwd |
Line width of the base map polygon borders. default: Any numeric value. |
map.lty |
Line type of the base map polygon borders. default: See |
facet |
Deprecated. Please use |
... |
Arguments passed on to
|
A ggplot2
plot
trajLevelMap()
for the interactive leaflet
equivalent of
trajLevelMapStatic()
Other static trajectory maps:
trajMapStatic()
leaflet
This function plots back trajectories on a leaflet
map. This function
requires that data are imported using the openair::importTraj()
function.
Options are provided to colour the individual trajectories (e.g., by
pollutant concentrations) or create "layer control" menus to show/hide
different layers.
trajMap( data, longitude = "lon", latitude = "lat", colour = NULL, type = NULL, cols = "default", alpha = 0.5, npoints = 12, provider = "OpenStreetMap", legend.position = "topright", legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control = NULL, ... )
trajMap( data, longitude = "lon", latitude = "lat", colour = NULL, type = NULL, cols = "default", alpha = 0.5, npoints = 12, provider = "OpenStreetMap", legend.position = "topright", legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control = NULL, ... )
data |
A data frame containing a HYSPLIT trajectory, perhaps accessed
with required A data frame containing HYSPLIT model outputs. If this data were not
obtained using |
latitude , longitude
|
The decimal latitude/longitude. default: Column names representing the decimal latitude and longitude. |
colour |
Column to be used for colouring each trajectory. default: This column may be numeric, character, factor or date(time). This will
commonly be a pollutant concentration which has been joined (e.g., by
|
type |
A method to condition the default: Used for splitting the trajectories into different groups which can be
selected between using a "layer control" menu. Passed to
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for trajectories. default: A value between |
npoints |
Interval at which points are placed along the trajectory paths. default: A dot is placed every |
provider |
The basemap to be used. default: A single leaflet::providers. See http://leaflet-extras.github.io/leaflet-providers/preview/ for a list of all base maps that can be used. |
legend.position |
Position of the shared legend. default: Where should the legend be placed? One of "topright", "topright",
"bottomleft" or "bottomright". Passed to the |
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: Should the "layer control" interface be collapsed? If |
control.position |
Position of the layer control menu default: Where should the "layer control" interface be placed? One of "topleft",
"topright", "bottomleft" or "bottomright". Passed to the |
control |
Deprecated. Please use |
... |
Arguments passed on to
|
A leaflet object.
trajMapStatic()
for the static ggplot2
equivalent of trajMap()
Other interactive trajectory maps:
trajLevelMap()
## Not run: trajMap(traj_data, colour = "pm10") ## End(Not run)
## Not run: trajMap(traj_data, colour = "pm10") ## End(Not run)
ggplot2
This function plots back trajectories using ggplot2
. The function
requires that data are imported using openair::importTraj()
. It is a
ggplot2
implementation of openair::trajPlot()
with many of the same
arguments, which should be more flexible for post-hoc changes.
trajMapStatic( data, colour = "height", type = NULL, group = NULL, size = NULL, linewidth = size, longitude = "lon", latitude = "lat", npoints = 12, xlim = NULL, ylim = NULL, crs = sf::st_crs(3812), origin = TRUE, map = TRUE, map.fill = "grey85", map.colour = "grey75", map.alpha = 0.8, map.lwd = 0.5, map.lty = 1, facet = NULL, ... )
trajMapStatic( data, colour = "height", type = NULL, group = NULL, size = NULL, linewidth = size, longitude = "lon", latitude = "lat", npoints = 12, xlim = NULL, ylim = NULL, crs = sf::st_crs(3812), origin = TRUE, map = TRUE, map.fill = "grey85", map.colour = "grey75", map.alpha = 0.8, map.lwd = 0.5, map.lty = 1, facet = NULL, ... )
data |
A data frame containing a HYSPLIT trajectory, perhaps accessed
with required A data frame containing HYSPLIT model outputs. If this data were not
obtained using |
colour |
Data column to map to the colour of the trajectories. default: This column may be numeric, character, factor or date(time). This will
commonly be a pollutant concentration which has been joined (e.g., by
|
type |
A method to condition the default: Used for splitting the trajectories into different groups which will appear
as different panels. Passed to |
group |
Column to use to distinguish different trajectory paths. default: By default, trajectory paths are distinguished using the arrival date.
|
size , linewidth
|
Data column to map to the size/width of the trajectory marker/paths, or absolute size value. default: Similar to the |
latitude , longitude
|
The decimal latitude/longitude. default: Column names representing the decimal latitude and longitude. |
npoints |
Interval at which points are placed along the trajectory paths. default: A dot is placed every |
xlim , ylim
|
The x- and y-limits of the plot. default: A numeric vector of length two defining the x-/y-limits of the map, passed
to |
crs |
The coordinate reference system (CRS) into which all data should be projected before plotting. default: This argument defaults to the Lambert projection, but can take any
coordinate reference system to pass to the |
origin |
Draw the receptor point as a circle? default: When |
map |
Draw a base map? default: Draws the geometries of countries under the trajectory paths. |
map.fill |
Colour to use to fill the polygons of the base map. default: See |
map.colour |
Colour to use for the polygon borders of the base map. default: See |
map.alpha |
Transparency of the base map polygons. default: Must be between |
map.lwd |
Line width of the base map polygon borders. default: Any numeric value. |
map.lty |
Line type of the base map polygon borders. default: See |
facet |
Deprecated. Please use |
... |
Arguments passed on to
|
a ggplot2
plot
trajMap()
for the interactive leaflet
equivalent of
trajMapStatic()
Other static trajectory maps:
trajLevelMapStatic()
## Not run: # colour by height trajMapStatic(traj_data) + ggplot2::scale_color_gradientn(colors = openair::openColours()) # colour by PM10, log transform scale trajMapStatic(traj_data, colour = "pm10") + ggplot2::scale_color_viridis_c(trans = "log10") + ggplot2::labs(color = openair::quickText("PM10")) # color by PM2.5, lat/lon projection trajMapStatic(traj_data, colour = "pm2.5", crs = sf::st_crs(4326)) + ggplot2::scale_color_viridis_c(option = "turbo") + ggplot2::labs(color = openair::quickText("PM2.5")) ## End(Not run)
## Not run: # colour by height trajMapStatic(traj_data) + ggplot2::scale_color_gradientn(colors = openair::openColours()) # colour by PM10, log transform scale trajMapStatic(traj_data, colour = "pm10") + ggplot2::scale_color_viridis_c(trans = "log10") + ggplot2::labs(color = openair::quickText("PM10")) # color by PM2.5, lat/lon projection trajMapStatic(traj_data, colour = "pm2.5", crs = sf::st_crs(4326)) + ggplot2::scale_color_viridis_c(option = "turbo") + ggplot2::labs(color = openair::quickText("PM2.5")) ## End(Not run)
The windroseMap()
function creates a map using wind roses as markers.
Multiple layers of markers can be created using the type
argument. By
default, these maps are dynamic and can be panned, zoomed, and otherwise
interacted with. Using the static
argument allows for static images to be
produced instead.
windroseMap( data, ws.int = 2, breaks = 4, latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
windroseMap( data, ws.int = 2, breaks = 4, latitude = NULL, longitude = NULL, crs = 4326, type = NULL, popup = NULL, label = NULL, provider = "OpenStreetMap", cols = "turbo", alpha = 1, key = FALSE, legend = TRUE, legend.position = NULL, legend.title = NULL, legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", control.autotext = TRUE, d.icon = 200, d.fig = 3.5, static = FALSE, static.nrow = NULL, progress = TRUE, n.core = 1L, ..., control = NULL )
data |
Input data table with wind and geo-spatial information. required | scope: dynamic & static A data frame. The data frame must contain the data to plot the directional
analysis marker, which includes wind speed ( |
ws.int |
The wind speed interval of the colour axis. default: The wind speed interval. Default is 2 m/s but for low met masts with low mean wind speeds a value of 1 or 0.5 m/s may be better. |
breaks |
Specifier for the number of breaks of the colour axis. default: Most commonly, the number of break points for wind speed in
|
latitude , longitude
|
The decimal latitude(Y)/longitude(X). default: Column names representing the decimal latitude and longitude (or other Y/X
coordinate if using a different |
crs |
The coordinate reference system (CRS). default: The coordinate reference system (CRS) of the data, passed to
|
type |
A method to condition the default: Used for splitting the input data into different groups, passed to the
|
popup |
Content for marker popups on dynamic maps. default: Columns to be used as the HTML content for marker popups on dynamic maps.
Popups may be useful to show information about the individual sites (e.g.,
site names, codes, types, etc.). If a vector of column names are provided
they are passed to |
label |
Content for marker hover-over on dynamic maps. default: Column to be used as the HTML content for hover-over labels. Labels are useful for the same reasons as popups, though are typically shorter. |
provider |
The basemap(s) to be used. default: The base map(s) to be used beneath the polar markers. If not provided, will
default to
There is some overlap in static and dynamic providers. For example,
|
cols |
Colours to use for plotting. default: The colours used for plotting, passed to |
alpha |
Transparency value for polar markers. default: A value between 0 (fully transparent) and 1 (fully opaque). |
key |
Draw individual marker legends? default: Draw a key for each individual marker? Potentially useful when |
legend |
Draw a shared legend? default: When all markers share the same colour scale (e.g., when |
legend.position |
Position of the shared legend. default: When
|
legend.title |
Title of the legend. default: By default, when |
legend.title.autotext |
Automatically format the title of the legend? default: When |
control.collapsed |
Show the layer control as a collapsed? default: For dynamic maps, should the "layer control" interface be collapsed? If
|
control.position |
Position of the layer control menu default: When |
control.autotext |
Automatically format the content of the layer control menu? default: When |
d.icon |
The diameter of the plot on the map in pixels. default: This will affect the size of the individual polar markers. Alternatively, a
vector in the form |
d.fig |
The diameter of the plots to be produced using default: This will affect the resolution of the markers on the map. Alternatively, a
vector in the form |
static |
Produce a static map? default: This controls whether a dynamic or static map is produced. The former is the default and is broadly more useful, but the latter may be preferable for DOCX or PDF outputs (e.g., academic papers). |
static.nrow |
Number of rows in a static map. default: Controls the number of rows of panels on a static map when multiple
|
progress |
Show a progress bar? default: By default, a progress bar is shown to visualise the function's progress creating individual polar markers. This option allows this to be turned off, if desired. |
n.core |
Number of cores to use in parallel processing. default: By default, each polar marker is drawn and saved sequentially. For big maps
with a lot of markers, this can be slow. Adjusting |
... |
Arguments passed on to
|
control |
Deprecated. Please use |
Either:
Dynamic: A leaflet object
Static: A ggplot2
object using ggplot2::coord_sf()
coordinates with a ggspatial
basemap
As the outputs of the static directional analysis functions are ggplot2
figures, further customisation is possible using functions such as
ggplot2::theme()
, ggplot2::guides()
and ggplot2::labs()
.
If multiple pollutants are specified, subscripting (e.g., the "x" in "NOx")
is achieved using the ggtext package. Therefore if you
choose to override the plot theme, it is recommended to use
[ggplot2::theme()]
and [ggtext::element_markdown()]
to define the
strip.text
parameter.
When arguments like limits
, percentile
or breaks
are defined, a
legend is automatically added to the figure. Legends can be removed using
ggplot2::theme(legend.position = "none")
, or further customised using
ggplot2::guides()
and either color = ggplot2::guide_colourbar()
for
continuous legends or fill = ggplot2::guide_legend()
for discrete
legends.
Other directional analysis maps:
annulusMap()
,
diffMap()
,
freqMap()
,
percentileMap()
,
polarMap()
,
pollroseMap()
## Not run: windroseMap(polar_data, provider = "CartoDB.Voyager" ) ## End(Not run)
## Not run: windroseMap(polar_data, provider = "CartoDB.Voyager" ) ## End(Not run)