Learn R Programming

openair (version 0.5-23)

trajLevel: Trajectory plots with conditioning

Description

This function plots back trajectories. There are two related functions: trajPlot and trajLevel. These functions require that data are imported using the importTraj function.

Usage

trajLevel(mydata, lon = "lon", lat = "lat",
    pollutant = "pm10", type = "default", method = "level",
    smooth = FALSE, map = TRUE, lon.inc = 1.5,
    lat.inc = 1.5, ...)

  trajPlot(mydata, lon = "lon", lat = "lat",
    pollutant = "pm10", type = "default",
    method = "scatter", smooth = FALSE, map = TRUE,
    lon.inc = 1.5, lat.inc = 1.5, group = NA, ...)

Arguments

mydata
Data frame, the result of importing a trajectory file using importTraj
lon
Column containing the longitude, as a decimal.
lat
Column containing the latitude, as a decimal.
pollutant
Pollutant to be plotted.
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", "
method
For trajectory plots, either "scatter" or "level". The latter option bins the data according to the values of x.inc and y.inc.
smooth
Should the trajectory surface be smoothed?
map
Should a base map be drawn? If TRUE the world base map from the maps package is used.
lon.inc
The longitude-interval to be used for binning data when method = "level".
lat.inc
The latitude-interval to be used for binning data when method = "level".
...
other arguments are passed to cutData and scatterPlot. This provides access to arguments used in both these functions and functions that they in turn pass arguments on to. For example, plotTraj passes the
group
For trajPlot it is sometimes useful to group and colour trajectories according to a grouping variable. See example below.

Value

  • NULL

Details

Several types of trajectory plot are available. trajPlot by default will plot each lat/lon location showing the origin of each trajectory, if no pollutant is supplied. If a pollutant is given, by merging the trajectory data with concentration data (see example below) the trajectories are colour-coded by the concentration of pollutant. With a long time series there can be lots of overplotting making it difficult to gauge the overall concentration pattern. In these cases setting alpha to a low value e.g. 0.1 can help. For the investigation of a few days it can be useful to use plot.type = "l", which shows the back trajectories as continuous lines rather than individual points. Note that points help to show the duration an air mass spend in a particular location, whereas lines do not. An alternative way of showing the trajectories is to bin the points into latitude/longitude intervals and average the corresponding concentrations. For these purposes trajLevel should be used. A further useful refinement is to smooth the resulting surface, which is possible by setting smooth = TRUE.

See Also

importTraj to import trajectory data from the King's College server.

Examples

Run this code
# show a simple case with no pollutant i.e. just the trajectories
# let's check to see where the trajectories were coming from when
# Heathrow Airport was closed due to the Icelandic volcanic eruption
# 15--21 April 2010.
# import trajectories for London and plot
lond <- importTraj("london", 2010)
# well, HYSPLIT seems to think there certainly were conditions where trajectories
# orginated from Iceland...
trajPlot(selectByDate(lond, start = "15/4/2010", end = "21/4/2010"), plot.type = "l")

# plot by day, need a column that makes a date
lond$day <- as.Date(lond$date)
trajPlot(selectByDate(lond, start = "15/4/2010", end = "21/4/2010"), plot.type = "l",
type = "day")

# or show each day grouped by colour, with some other options set
trajPlot(selectByDate(lond, start = "15/4/2010", end = "21/4/2010"), plot.type = "l",
group = "day", col = "jet", lwd = 2, key.pos = "right", key.col = 1)
# more examples to follow linking with concentration measurements...

# import some measurements from KC1 - London
kc1 <- importAURN("kc1", year = 2010)
# now merge with trajectory data by 'date'
lond <- merge(lond, kc1, by = "date")

# trajectory plot, no smoothing - and limit lat/lon area of interest
trajLevel(subset(lond, lat > 40 & lat < 70 & lon >-20 & lon <20), pollutant = "pm10")

# can smooth surface:
trajLevel(subset(lond, lat > 40 & lat < 70 & lon >-20 & lon <20), pollutant = "pm2.5",
smooth = TRUE)

# plot by season:
trajLevel(subset(lond, lat > 40 & lat < 70 & lon >-20 & lon <20), pollutant = "pm2.5",
smooth = TRUE, type = "season")

Run the code above in your browser using DataLab