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

Share:

Description

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

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

voronoi(points, window)

Arguments

tessellation

Tessellation of class tess from the library spatstat. 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.

Details

This code is almost completely based on functions from the spatstat package. For convenience, first some geographical boundaries can easily be accessed and converted for use in spatstat. Then a voronoi tessellation can be made (based on the function dirichlet, which in turn is based on deldir). Finally, this tessalation 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").

Value

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

Author(s)

Michael Cysouw <cysouw@mac.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)