Skip to contents

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.


  longitude = "lon",
  latitude = "lat",
  control = "default",
  cols = "default",
  alpha = 0.5,
  npoints = 12,
  provider = "OpenStreetMap",
  collapse.control = FALSE



Data frame, the result of importing a trajectory file using openair::importTraj().

latitude, longitude

The decimal latitude/longitude.


Column to be used for colouring each trajectory. This column may be numeric, character or factor. This will commonly be a pollutant concentration which has been joined (e.g., by dplyr::left_join()) to the trajectory data by "date".


Used for splitting the trajectories into different groups which can be selected between using a "layer control" menu. Passed to openair::cutData().


Colours to be used for plotting. Options include "default", "increment", "heat", "turbo" and RColorBrewer colours — see the openair::openColours() function for more details. For user defined the user can supply a list of colour names recognised by R (type grDevices::colours() to see the full list). An example would be cols = c("yellow", "green", "blue"). If the "colour" argument was not used, a single colour can be named which will be used consistently for all lines/points (e.g., cols = "red").


Opacity of lines/points. Must be between 0 and 1.


A dot is placed every npoints along each full trajectory. For hourly back trajectories points are plotted every npoints hours. 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 to 12.


The base map to be used. See for a list of all base maps that can be used.


Should the "layer control" interface be collapsed? Defaults to FALSE.


A leaflet object.

See also

the original openair::trajPlot()

trajMapStatic() for the static ggplot2 equivalent of trajMap()

Other interactive trajectory maps: trajLevelMap()


if (FALSE) {
trajMap(traj_data, colour = "nox")