Learn R Programming

terra (version 0.2-9)

plot: Plot a SpatRaster or SpatVector

Description

Plot (that is, make a map of) the values of a SpatRaster or SpatVector

Usage

# S4 method for SpatRaster,numeric
plot(x, y, cols, maxcell=100000, leg.mar, 
		leg.levels=5, leg.shrink=c(0,0), leg.main=NULL, leg.main.cex=1, leg.ext,
		digits, useRaster=TRUE, zlim, xlab="", ylab="", ...)

# S4 method for SpatRaster,missing plot(x, y, maxcell=100000, nc, nr, main, maxnl=16, ...)

# S4 method for SpatRaster,SpatRaster plot(x, y, maxcell=100000, nc, nr, maxnl=16, gridded=FALSE, ncol=25, nrow=25, ...)

# S4 method for SpatRaster image(x, y, maxcell=100000, xlab="", ylab="", useRaster=TRUE, ...)

# S4 method for SpatVector,missing plot(x, y, xlab="", ylab="", add=FALSE, ...) # S4 method for SpatVector points(x, ...) # S4 method for SpatVector lines(x, ...) # S4 method for SpatExtent lines(x, ...)

Arguments

x

SpatRaster or SpatVector

y

missing or integer indicating the layer(s) to be plotted

cols

character. colors

maxcell

integer > 0. Maximum number of cells to use for the plot

leg.mar

integer > 0. size of margin for the legend

leg.levels

integer > 0. number of labels on the legend

leg.shrink

numeric. relative shrinkage of legend from top and bottom

leg.main

character. legend title

leg.main.cex

character. legend title size

leg.ext

SpatExtent or numeric vector indicating the area where to plot the legend. The vector should have a lenght of 4 (xmin, xmax, ymin, ymax)

digits

integer >= 0

zlim

range of allowed values

xlab

character

ylab

character

useRaster

logical; if TRUE plotting is faster because a bitmap raster is used to plot the image instead of polygons. See image

nc

integer > 0. Optional. The number of columns to divide the plotting device in (when plotting multiple layers)

nr

integer > 0. Optional. The number of rows to divide the plotting device in (when plotting multiple layers)

maxnl

integer > 0. Maximum number of layers to plot (for a multi-layer object)

main

character. Main plot title

gridded

logical. If TRUE the scatterplot is gridded (counts by cells)

ncol

integer. Number of columns for gridding

nrow

integer. Number of rows for gridding

add

Add points, lines, or polygons to the current plot (as an alternative to the lines or points methods

...

additional graphical arguments

Examples

Run this code
# NOT RUN {
f <- system.file("exdata/test.tif", package="terra") 
r <- rast(f)
plot(r)

d <- (r > 400) + (r > 600)
plot(d, leg.main="Title")
plot(d, leg.ext=c(178000,178200,332800,333250),
		leg.main=c("Title     \n\n"))

f <- system.file("exdata/lux.shp", package="terra")
v <- vect(f)
r <- rast(v)
values(r) <- 1:ncell(r)
plot(r)
lines(v)
points(v)
# }

Run the code above in your browser using DataLab