Skip to contents

This function carries out cluster analysis of HYSPLIT back trajectories. The function is specifically designed to work with the trajectories imported using the openair::importTraj() function, which provides pre-calculated back trajectories at specific receptor locations. Clustered trajectories can be visualised using traj_plot().

Usage

traj_cluster(
  data,
  method = "Euclid",
  n_clusters = 5,
  facet = NULL,
  split_after = FALSE,
  return = "plot",
  ...
)

Arguments

data

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

method

Method used to calculate the distance matrix for the back trajectories. There are two methods available: "Euclid" and "Angle".

n_clusters

Number of clusters to calculate.

facet

One or two faceting columns. facet determines how the data are split and then clustered. Note that the cluster calculations are separately made of each level of "type".

split_after

When facet != NULL, the trajectories can either be calculated for each facet independently or extracted after the cluster calculations have been applied to the whole data set.

return

"plot" (the default) or "data". "plot" will return plotted clusters for visual analysis so that an appropriate value for n_clusters can be selected. When such a value has been chosen, "data" will return the original data frame appended with a cluster column for use in, for example, trend_prop().

...

Arguments passed on to traj_plot

alpha

Transparency of the plots/lines, where 1 is completely opaque and 0 is completely transparent.

n_points

A dot is placed every n_points along each full trajectory. For hourly back trajectories points are plotted every npoint 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). If n_points = NULL then no points are added.

map

Should a base map be drawn? If TRUE the world base map from the maps package is used.

map_fill

Fill colour of map.

map_colour

Line colour of map.

map_alpha

Alpha of map.

lon_range,lat_range

Longitude and latitude range, provided as a numeric vector of length 2.

crs

The coordinate reference system (CRS) used for the base map. Defaults to 4326, which behaves similarly to Cartesian coordinates. A useful alternative could be 3035 (the "lambert" projection).

See also

Other trajectory analysis functions: traj_level(), traj_plot()