panel.voronoi: Panel functions for level-coded irregular points

Description Usage Arguments Details Author(s) See Also Examples

View source: R/tileplot.R

Description

These panel functions for levelplot can represent irregular (x, y) points with a color covariate. panel.levelplot.points simply draws color-coded points. panel.voronoi uses the deldir package to calculate the spatial extension of a set of points in 2 dimensions. This is known variously as a Voronoi mosaic, a Dirichlet tesselation, or Thiessen polygons.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
panel.voronoi(x, y, z, subscripts = TRUE, at = pretty(z),
   points = TRUE, border = "transparent",
   na.rm = FALSE, win.expand = 0.07, use.tripack = FALSE,
   ...,
   col.regions = regions$col, alpha.regions = regions$alpha)

panel.levelplot.points(x, y, z, subscripts = TRUE, at = pretty(z),
   shrink, labels, label.style, contour, region,
   pch = 21, col.symbol = "#00000044",
   ...,
   col.regions = regions$col, fill = NULL)

Arguments

x, y, z

an irregular set of points at locations (x, y) with value z.

subscripts

integer vector indicating what subset of x, y and z to draw. Typically passed by levelplot.

at, col.regions, alpha.regions

color scale definition; see panel.levelplot.

points

whether to draw the (x, y) points.

border

color for polygon borders.

na.rm

if TRUE, points with missing z values will be excluded from the calculation of polygons. If FALSE, those polygons are calculated but are not drawn (i.e. are transparent).

win.expand

defines the rectangular window bounding the polygons. This is a factor by which to expand the range of the data. Set to 0 to limit drawing at the furthest data point locations. Ignored if use.tripack = TRUE.

use.tripack

if TRUE, use tripack package rather than deldir. See Details.

...

further arguments are passed to panel.xyplot if points = TRUE.

pch, col.symbol

symbol and border color for points. A filled symbol should be used, i.e. in the range 21-25.

shrink, labels, label.style, contour, region, fill

ignored.

Details

The tripack package implementation is faster than deldir but not under a fully free licence. Also, the deldir package allows polygons to be clipped to a rectangular window (the win.expand argument).

Author(s)

Felix Andrews felix@nfrac.org

See Also

tileplot, panel.levelplot, deldir

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## a variant of Figure 5.6 from Sarkar (2008)
## http://lmdvr.r-forge.r-project.org/figures/figures.html?chapter=05;figure=05_06

depth.ord <- rev(order(quakes$depth))
quakes$Magnitude <- equal.count(quakes$mag, 4)
quakes.ordered <- quakes[depth.ord, ]

levelplot(depth ~ long + lat | Magnitude, data = quakes.ordered,
         panel = panel.levelplot.points, type = c("p", "g"),
         aspect = "iso", prepanel = prepanel.default.xyplot)

## a levelplot with jittered cells

xyz <- expand.grid(x = 0:9, y = 0:9)
xyz[] <- jitter(as.matrix(xyz))
xyz$z <- with(xyz, sqrt((x - 5)^2 + (y - 5)^2))
levelplot(z ~ x * y, xyz, panel = panel.voronoi, points = FALSE)

## hexagonal cells

xyz$y <- xyz$y + c(0, 0.5)
levelplot(z ~ x * y, xyz, panel = panel.voronoi, points = FALSE)

Example output

Loading required package: lattice
Loading required package: RColorBrewer

     PLEASE NOTE:  The components "delsgs" and "summary" of the
 object returned by deldir() are now DATA FRAMES rather than
 matrices (as they were prior to release 0.0-18).
 See help("deldir").
 
     PLEASE NOTE: The process that deldir() uses for determining
 duplicated points has changed from that used in version
 0.0-9 of this package (and previously). See help("deldir").

latticeExtra documentation built on Sept. 19, 2020, 3:01 p.m.