Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

text

Add labels to a map


Description

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

Usage

## S4 method for signature 'SpatRaster'
text(x, labels, digits=0, halo=FALSE, ...)

## S4 method for signature 'SpatVector'
text(x, labels, halo=FALSE, ...)

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. If TRUE, additional arguments hc="white" and hw=0.1 can be modified to set the colour and width of the halo

...

additional arguments to pass to graphics function text

See Also

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)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.