lineLabel

0th

Percentile

Label placement with spplot and lattice.

Use optimization routines to find good locations for point labels without overlaps.

Usage
lineLabel(line, label,
                     spar=.6, position = c('above', 'below'),
                     col = add.text$col,
                     alpha = add.text$alpha,
                     cex = add.text$cex,
                     lineheight = add.text$lineheight,
                     font = add.text$font,
                     fontfamily = add.text$fontfamily,
                     fontface = add.text$fontface,
                     lty = add.line$lty,
                     lwd = add.line$lwd, 
                     col.line = add.line$col,
                     identifier = 'lineLabel',
                     ...)
sp.lineLabel(object, labels, ...)
Arguments
line
a Lines or SpatialLines object.
object
A SpatialLines object.
label, labels
a string or expression to be printed following the path of line. Its names should match the values of the ID slot of the lines to label. If label is missing, the ID slot is used
spar
smoothing parameter. With values near zero, the label will closely follow the line. Default value is .6. See smooth.spline for details.
position
character string ('above' or 'below') to define where the text must be placed.
col, alpha, cex, lineheight, font, fontfamily, fontface
graphical arguments for the text. See gpar for details.
lty, lwd, col.line
graphical parameters for the line. See gpar for details.
identifier
A character string to identify the grob to be created.
...
other arguments
Details

The label location code is adapted from panel.levelplot. The part of the line where the text is placed is resampled with smooth.spline.

See Also

spplot pointLabel panel.levelplot smooth.spline

Aliases
  • lineLabel
  • sp.lineLabel
  • sp.lineLabel-methods
  • sp.lineLabel,Lines-method
  • sp.lineLabel,SpatialLines-method
Examples
data(meuse.grid)
coordinates(meuse.grid) = ~x+y
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
gridded(meuse.grid) = TRUE

data(meuse)
coordinates(meuse) = ~x+y
data(meuse.riv)
meuse.sl <- SpatialLines(list(Lines(list(Line(meuse.riv)), "1")))

ids <- sapply(meuse.sl@lines, function(l)l@ID)
labs <- 'Meuse River'
names(labs) <- ids

library(RColorBrewer)
myCols <- adjustcolor(colorRampPalette(brewer.pal(n=9, 'Reds'))(100), .85)

sl1 <- list('sp.lineLabel', meuse.sl, label=labs,
            position='below',
            spar=.2,
            col='darkblue', cex=1,
            fontfamily='Palatino',
            fontface=2)

spplot(meuse.grid["dist"],
       col.regions=myCols, 
       sp.layout = sl1)
Documentation reproduced from package maptools, version 0.8-20, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.