| layout.labels | R Documentation |
spplot
Generate sp.layout items for use by spplot
or plot these items directly in the traditional graphics system.
Function layout.labels draws labels at the coordinates of the
spatial object, and layout.scalebar returns a labeled scale bar.
layout.labels(obj, labels = TRUE, plot = FALSE)
layout.scalebar(obj, corner = c(0.05, 0.95), scale = 1,
labels = c(0, scale), height = 0.05,
pos = 3, ..., plot = FALSE)
obj |
an object inheriting from a |
labels |
specification of the labels. For
For |
corner |
the location of the scale bar in the unit square, where
|
scale |
the width of the scale bar in the units of |
height |
the height of the scale bar, see |
pos |
a position specifier for the labels (see |
... |
further arguments for |
plot |
logical indicating if the layout item should be plotted using the
traditional graphics system. By default ( |
For layout.labels, a single sp.layout item, which is
a list with first element "panel.text" and subsequent elements
being arguments to that function based on the labels
specification.
For layout.scalebar, a list of sp.layout items
comprising the polygonal scale bar and the labels.
If these layout functions are called with plot = TRUE,
the item is plotted directly using traditional graphics functions
and NULL is returned.
Sebastian Meyer
## districts in the Regierungsbezirk Weser-Ems (longlat coordinates)
data("measlesWeserEms")
mapWE <- measlesWeserEms@map
li1 <- layout.labels(mapWE, labels = list(font=2, labels="GEN"))
li2 <- layout.scalebar(mapWE, corner = c(0.05, 0.05), scale = 20,
labels = c("0", "20 km"))
spplot(mapWE, zcol = "AREA", sp.layout = c(list(li1), li2),
col.regions = rev(heat.colors(100)), scales = list(draw = TRUE))
## districts in Bavaria (projected coordinates)
load(system.file("shapes", "districtsD.RData", package = "surveillance"))
bavaria <- districtsD[substr(row.names(districtsD), 1, 2) == "09", ]
sb <- layout.scalebar(bavaria, corner = c(0.75,0.9), scale = 50,
labels = c("0", "50 km"), cex = 0.8)
spplot(bavaria, zcol = "POPULATION", sp.layout = sb,
xlab = "x [km]", ylab = "y [km]", scales = list(draw = TRUE),
col.regions = rev(heat.colors(100)))
## these layout functions also work in the traditional graphics system
par(mar = c(0,0,0,0))
plot(bavaria, col = "lavender")
layout.scalebar(bavaria, corner = c(0.75, 0.9), scale = 50,
labels = c("0", "50 km"), plot = TRUE)
layout.labels(bavaria, labels = list(cex = 0.8,
labels = substr(bavaria$GEN, 1, 3)), plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.