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.
Usage
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,
...
)Arguments
- data
A data frame containing a HYSPLIT trajectory, perhaps accessed with
openair::importTraj().required
A data frame containing HYSPLIT model outputs. If this data were not obtained using
openair::importTraj().- colour
Data column to map to the colour of the trajectories.
default:
NULLThis column may be numeric, character, factor or date(time). This will commonly be a pollutant concentration which has been joined (e.g., by
dplyr::left_join()) to the trajectory data by "date". The scale can be edited after the fact usingggplot2::scale_color_continuous()or similar.- type
A method to condition the
datafor separate plotting.default:
NULLUsed for splitting the trajectories into different groups which will appear as different panels. Passed to
openair::cutData().- group
Column to use to distinguish different trajectory paths.
default:
NULLBy default, trajectory paths are distinguished using the arrival date.
groupallows for additional columns to be used (e.g.,"receptor"if multiple receptors are being plotted).- size, linewidth
Data column to map to the size/width of the trajectory marker/paths, or absolute size value.
default:
NULLSimilar to the
colourargument, this defines a column to map to the size of the circular markers or the width of the paths. These scales can be edited after the fact usingggplot2::scale_size_continuous(),ggplot2::scale_linewidth_continuous(), or similar. If numeric, the value will be directly provided toggplot2::geom_point(size = )orggplot2::geom_path(linewidth = ).- latitude, longitude
The decimal latitude/longitude.
default:
"lat"/"lon"Column names representing the decimal latitude and longitude.
- npoints
Interval at which points are placed along the trajectory paths.
default:
12A dot is placed every
npointsalong each full trajectory. For hourly back trajectories points are plotted everynpointshours. This helps to understand where the air masses were at particular times and get a feel for the speed of the air (points closer together correspond to slower moving air masses). Defaults to12.- xlim, ylim
The x- and y-limits of the plot.
default:
NULLA numeric vector of length two defining the x-/y-limits of the map, passed to
ggplot2::coord_sf(). IfNULL, limits will be estimated based on the lat/lon ranges of the input data.- crs
The coordinate reference system (CRS) into which all data should be projected before plotting.
default:
sf::st_crs(3812)This argument defaults to the Lambert projection, but can take any coordinate reference system to pass to the
crsargument ofggplot2::coord_sf(). Alternatively,crscan be set toNULL, which will typically render the map quicker but may cause countries far from the equator or large areas to appear distorted.- origin
Draw the receptor point as a circle?
default:
TRUEWhen
TRUE, the receptor point(s) are marked with black circles.- map
Draw a base map?
default:
TRUEDraws the geometries of countries under the trajectory paths.
- map.fill
Colour to use to fill the polygons of the base map.
default:
"grey85"See
colors()for colour options. Alternatively, a hexadecimal color code can be provided.- map.colour
Colour to use for the polygon borders of the base map.
default:
"grey75"See
colors()for colour options. Alternatively, a hexadecimal color code can be provided.- map.alpha
Transparency of the base map polygons.
default:
0.8Must be between
0(fully transparent) and1(fully opaque).- map.lwd
Line width of the base map polygon borders.
default:
0.5Any numeric value.
- map.lty
Line type of the base map polygon borders.
default:
1See
ggplot2::scale_linetype()for common examples. The default,1, draws solid lines.- facet
Deprecated. Please use
type.- ...
Arguments passed on to
openair::cutDatanamesBy default, the columns created by
cutData()are named after theirtypeoption. Specifyingnamesdefines other names for the columns, which map onto thetypeoptions in the same order they are given. The length ofnamesshould therefore be equal to the length oftype.suffixIf
nameis not specified,suffixwill be appended to any added columns that would otherwise overwrite existing columns. For example,cutData(mydata, "nox", suffix = "_cuts")would append anox_cutscolumn rather than overwritingnox.hemisphereCan be
"northern"or"southern", used to split data into seasons.n.levelsNumber of quantiles to split numeric data into.
start.dayWhat day of the week should the
type = "weekday"start on? The user can change the start day by supplying an integer between 0 and 6. Sunday = 0, Monday = 1, ... For example to start the weekday plots on a Saturday, choosestart.day = 6.is.axisA logical (
TRUE/FALSE), used to request shortened cut labels for axes.local.tzUsed for identifying whether a date has daylight savings time (DST) applied or not. Examples include
local.tz = "Europe/London",local.tz = "America/New_York", i.e., time zones that assume DST. https://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones shows time zones that should be valid for most systems. It is important that the original data are in GMT (UTC) or a fixed offset from GMT.latitude,longitudeThe decimal latitude and longitudes used when
type = "daylight". Note that locations west of Greenwich have negative longitudes.
See also
trajMap() for the interactive leaflet equivalent of
trajMapStatic()
Other static trajectory maps:
trajLevelMapStatic()
Examples
if (FALSE) { # \dontrun{
# 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"))
} # }
