Learn R Programming

raster (version 1.8-3)

plot: Plot a Raster* object

Description

Plot (that is, make a map of) the values of a Raster* object, or make a scatterplot of their values. Points, lines, and polygons can be drawn on top of a map using plot(..., add=TRUE), or functions like points, lines, polygons text plots a textual (rather than color) representation of values of the cells on top of the cells.

Arguments

Methods

x=RasterLayer plot(x, col=rev(terrain.colors(25)), maxpixels=100000, axes = TRUE, xlab="", ylab="", alpha=1, ...) rll{ x a RasterLayer object col A color palette, i.e. a vector of n contiguous colors such as rainbow, heat.colors, and topo.colors, or one or your own making maxpixels Maximum number of pixels used for the map alpha Number between 0 and 1 to set transparancy. 0 is entirely transparant, 1 is not transparant ... Any argument that can be passed to image.plot and to plot } If x has a 'Color table', the default all to plot is: plot(x, maxpixels=500000, ext=NULL, interpolate=FALSE, axes=FALSE, xlab="", ylab="", ...) rll{ ext An extent object to zoom in a region interpolate Logical. Should the image be interpolated? axes Logical. Should axes be drawn? ... Graphical parameters } x=RasterStack or RasterBrick, y=numeric or missing plot(x, col=rev(terrain.colors(25)), subsample=TRUE, maxpixels=100000, alpha=1, axes=TRUE, xlab="", ylab="", ...) rll{ x a RasterStack or RasterBrick object y The index of a RasterLayer in a RasterStack to be plotted. Either a single number between 1 and nlayers(rstack), a vector of numbers, or missing. If y is missing, all RasterLayers in the RasterStack will be plotted. col A color palette, i.e. a vector of n contiguous colors such as rainbow, heat.colors, and topo.colors, or one or your own making maxpixels Maximum number of pixels used for the map alpha Number between 0 and 1 to set transparancy. 0 is entirely transparant, 1 is not transparant axes see ?image xlab see ?image ylab see ?image ... Any argument that can be passed to image.plot and to plot } x=RasterLayer, y=RasterLayer Produces a scatter plot of the values of x against those of y. plot(x, y, maxpixels=100000, cex=0.1, ...) rll{ x a RasterLayer object y a RasterLayer object maxpixels Maximum number of pixels in the map display cex point size ... Any argument that can be passed to plot } x=Extent, y="ANY" Draws the (rectangular) bounding box of a raster object. plot(ext) rll{ ext a Extent object }

Details

Most of the code for this function was taken from image.plot (fields package). Raster objects with a color-table (e.g. a graphics file) will be plotted according to the color table.

See Also

plotRGB, plot3D, persp, contour, pairs, hist

Examples

Run this code
# RasterLayer
r <- raster(nrows=10, ncols=10)
r <- setValues(r, 1:ncell(r))
plot(r)
text(r)

e <- extent(r)
plot(e, add=TRUE, col='red', lwd=4)
e <- e / 2
plot(e, add=TRUE, col='red')


# Scatterplot of 2 RasterLayers
r2 <- sqrt(r)
plot(r, r2)

# Multi-layer object (RasterStack / Brick)
s <- stack(r, r2, r/r)
plot(s, 2)
plot(s)

Run the code above in your browser using DataLab