text function

Add labels to a map

Add labels to a map

Plots labels, that is a textual (rather than color) representation of values, on top an existing plot (map). methods

## S4 method for signature 'SpatRaster' text(x, labels, digits=0, halo=FALSE, hc="white", hw=0.1, ...) ## S4 method for signature 'SpatVector' text(x, labels, halo=FALSE, inside=FALSE, hc="white", hw=0.1, ...)

Arguments

  • x: SpatRaster or SpatVector
  • labels: character. Optional. Vector of labels with length(x) or a variable name from names(x)
  • digits: integer. How many digits should be used?
  • halo: logical. If TRUE a "halo" is printed around the text
  • hc: character. The halo color
  • hw: numeric. The halo width
  • inside: logical. Should the text always be placed inside one the sub-geometries?
  • ...: additional arguments to pass to graphics function text

See Also

text, plot, halo

Examples

r <- rast(nrows=4, ncols=4) values(r) <- 1:ncell(r) plot(r) text(r) plot(r) text(r, halo=TRUE, hc="blue", col="white", hw=0.2) plot(r, col=rainbow(16)) text(r, col=c("black", "white"), vfont=c("sans serif", "bold"), cex=2)
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-02-26