Learn R Programming

qlcVisualize (version 0.4)

vmap: Plotting a Voronoi-map ("v-map")

Description

These functions are deprecated: use weightedMap instead.

A Voronoi-map (voronoi-tessellation, also known as dirichlet tessellation) is used in quantitative dialectology. This function is a convenience wrapper to easily produce dialect maps with voronoi tessellations. Also described here are a helper functions to produce the tessellation.

Usage

vmap(tessellation, col = NULL, add = FALSE,
  outer.border = "black", border = "grey", lwd = 1, ...)

voronoi(points, window)

Value

voronoi returns a tessellation of the class tess from the package spatstat.geom. When points outside of the border are attested, the indices of these points are added to an attribute "rejects". vmap plots a map.

Arguments

tessellation

Tessellation of class tess from the library spatstat.geom. Can easily be produces by using the convenience function voronoi provided here.

col

Vector of colors for the filling of the tessellation. Is recycled when there are more tiles than colours. The order of the tiles is the same as the order of the points as specified in the function voronoi.

add

Add graphics to an existing plot

outer.border

Colour of the outer border. Specifying NA removes the border.

border

Colour of the inner borders. Specifying NA removes all borders.

lwd

Line width of borders.

...

Further arguments passed to polygon.

points

Two-column matrix with all coordinates of the points to make a Voronoi tessellation.

window

Outer boundary for the Voronoi tessellation. Should be in the form of an owin object. There are two helper functions provided here to get such object. Note that the function voronoi will give warnings if there are points outside of this window.

Author

Michael Cysouw <cysouw@mac.com>

Details

This code is almost completely based on functions from the spatstat.geom package. For convenience, first some geographical boundaries can easily be accessed and converted for use in spatstat.geom. Then a Voronoi tessellation can be made (based on the function dirichlet, which in turn is based on deldir from the package deldir). Finally, this tessellation can be plotted filled with different colours.

Any legends have to be added manually by using legend, see examples below.

The function voronoi returns a warning when points are attested that lie outside of the specified border. For these points there is no polygon specified. Indices for the rejected points outside the border can be accessed by attr(x, "rejects").

Examples

Run this code
if (FALSE) {
# make a Voronoi tessellation for some villages in hessen
data(hessen)
plot(hessen$boundary)
points(hessen$villages, cex = 0.3)

tessellation <- voronoi(hessen$villages, hessen$boundary)
plot(tessellation)

# make a resizable plot with random colour specification
vmap(tessellation, col = rainbow(5), border = NA)
legend("bottomright", legend = c("a","b","c","d","e"), fill = rainbow(5))

# use actual colors from data, using first feature from supplied data
# multiple levels cannot easily be shown
# consider \link{lmap} for more detail
d1 <- hessen$data[,1:3]
d1 <- d1[,1]/rowSums(d1)
vmap(tessellation, col = rgb(1, 1-d1, 1-d1))
text(hessen$villages,labels=hessen$data[,1],cex=.5)
legend("bottomright", legend = c("es mir", "mir es / other"),
  fill = c("red", "white"))

# Use distances to determine colour, as proposed by Heeringa (2004)
# Note that different methods to establish distances can lead to rather
# different results! Also try method = "euclidean"
d <- dist(hessen$data, method = "canberra")
cols <- heeringa(d)
vmap(tessellation, col = cols, border = NA)
}

Run the code above in your browser using DataLab