Learn R Programming

openair (version 1.5)

trajCluster: Calculate clusters for back tracectories

Description

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.

Usage

trajCluster(traj, method = "Euclid", n.cluster = 5, plot = TRUE,
  type = "default", cols = "Set1", split.after = FALSE, map.fill = TRUE,
  map.cols = "grey40", map.alpha = 0.4, projection = "lambert",
  parameters = c(51, 51), orientation = c(90, 0, 0), ...)

Arguments

traj
An openair trajectory data frame resulting from the use of importTraj.
method
Method used to calculate the distance matrix for the back trajectories. There are two methods available: Euclid and Angle.
n.cluster
Number of clusters to calculate.
plot
Should a plot be produced?
type
type determines how the data are split i.e. conditioned, and then plotted. The default is will produce a single plot using the entire data. Type can be one of the built-in types as detailed in cutData e.g. season
cols
Colours to be used for plotting. Options include default, increment, heat, jet and RColorBrewer colours --- see the openair openColours function
split.after
For type other than default e.g. season, the trajectories can either be calculated for each level of type independently or extracted after the cluster calculations have been applied to the who
map.fill
Should the base map be a filled polygon? Default is to fill countries.
map.cols
If map.fill = TRUE map.cols controls the fill colour. Examples include map.fill = "grey40" and map.fill = openColours("default", 10). The latter colours the countries and can help differentiate them.
map.alpha
The transpency level of the filled map which takes values from 0 (full transparency) to 1 (full opacity). Setting it below 1 can help view trajectories, trajectory surfaces etc. and a filled base map.
projection
The map projection to be used. Different map projections are possible through the mapproj package. See?mapproj for extensive details and information on setting other parameters and orientation (see below).
parameters
From the mapproj package. Optional numeric vector of parameters for use with the projection argument. This argument is optional only in the sense that certain projections do not require additional parameters. If a projection does require
orientation
From the mapproj package. An optional vector c(latitude,longitude,rotation) which describes where the "North Pole" should be when computing the projection. Normally this is c(90,0), which is appropriate for cylindrical and conic projectio
...
Other graphical parameters passed onto lattice:levelplot and cutData. Similarly, common axis and title labelling options (such as xlab, ylab, main) are passed to levelplot vi

Value

  • Returns original data frame with a new (factor) variable cluster giving the calculated cluster.

Details

Two main methods are available to cluster the back trajectories using two different calculations of the distance matrix. The default is to use the standard Euclidian distance between each pair of trajectories. Also available is an angle-based distance matrix based on Sirois and Bottenheim (1995). The latter method is useful when the interest is the direction of the trajectories in clustering. The distance matrix calculations are made in C++ for speed. For data sets of up to 1 year both methods should be relatively fast, although the method = "Angle" does tend to take much longer to calculate. Further details of these methods are given in the openair manual.

References

Sirois, A. and Bottenheim, J.W., 1995. Use of backward trajectories to interpret the 5-year record of PAN and O3 ambient air concentrations at Kejimkujik National Park, Nova Scotia. Journal of Geophysical Research, 100: 2867-2881.

See Also

importTraj, trajPlot, trajLevel

Examples

Run this code
## import trajectories
traj <- importTraj(site = "london", year = 2009)
## calculate clusters
traj <- trajCluster(traj, n.clusters = 5)
head(traj) ## note new variable 'cluster'
## use different distance matrix calculation, and calculate by season
traj <- trajCluster(traj, method = "Angle", type = "season", n.clusters = 4)

Run the code above in your browser using DataLab