terra (version 0.3-7)

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, col, maxcell=100000, leg.mar=NULL, 
		leg.levels=5, leg.shrink=c(0,0), leg.main=NULL, leg.main.cex=1, leg.ext=NULL,
		digits, useRaster=TRUE, zlim, xlab="", ylab="", axes=TRUE, add=FALSE, ...)

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

# S4 method for SpatVector,missing plot(x, y, col=NULL, xlab="", ylab="", axes=TRUE, add=FALSE, ...)

# S4 method for SpatVector,character plot(x, y, col=topo.colors(100), xlab="", ylab="", axes=TRUE, add=FALSE, leg.ext=NULL, leg.type=NULL, leg.levels=5, digits, ...)

# S4 method for SpatExtent,missing plot(x, y, col=NULL, xlab="", ylab="", axes=TRUE, ...)

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

# S4 method for SpatVector points(x, col=NULL, ...) # S4 method for SpatVector lines(x, col=NULL, ...) # S4 method for SpatExtent points(x, col=NULL, ...) # S4 method for SpatExtent lines(x, col=NULL, ...)

Arguments

x

SpatRaster or SpatVector

y

missing or positive integer indicating the layer(s) to be plotted, or the name of the layer to be mapped

col

character. Colors

maxcell

positive integer. Maximum number of cells to use for the plot

leg.mar

positive integer. Size of margin for the legend

leg.levels

positive integer. 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)

leg.type

character. Legend type

digits

integer >= 0

zlim

range of allowed values

xlab

character

ylab

character

axes

logical

useRaster

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

nc

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

nr

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

maxnl

postive integer. 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

positive integer. Number of columns for gridding

nrow

positive integer. Number of rows for gridding

add

logical. If TRUE add the object to the current plot (for points, lines, and polygons this is 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"))

# character labels
x <- round(r/1000)
x <- as.factor(x)
levels(x) <- c("earth", "wind", "fire")
plot(x)


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