Learn R Programming

geometr (version 0.2.5)

visualise: Visualise raster and geom objects

Description

Visualise raster and geom objects

Usage

visualise(
  ...,
  layer = NULL,
  window = NULL,
  theme = gtTheme,
  trace = FALSE,
  image = FALSE,
  new = TRUE,
  clip = TRUE
)

Arguments

...

objects to plot and optional graphical parameters.

layer

[integerish(.) | character(.)] in case the objects to plot have several layers, this is the name or index of the layer(s) that shall be plotted.

window

[data.frame(1)] two opposing corners of a rectangle to which the plot is limited.

theme

[list(7)] visualising options; see setTheme for details.

trace

[logical(1)] Print the raster object's history (i.e. the process according to which it has been created) (TRUE), or simply plot the object (FALSE, default).

image

[logical(1)] set this to TRUE if raster is actually an image; see Details.

new

[logical(1)] force a new plot (TRUE, default).

clip

[logical(1)] clip the plot by the plot box (TRUE, default), or plot all of the objects.

Value

Returns invisibly an object of class recordedplot, see recordPlot for details (and warnings).

Details

In case you want to plot an image (similar to plotRGB), you either have to:

  1. provide a RasterStack with the three layers red, green and blue or

  2. provide a matrix with hexadecimal colour values (e.g. '#000000')

and set image = TRUE.

Examples

Run this code
# NOT RUN {
coords <- data.frame(x = c(30, 60, 60, 40),
                     y = c(40, 40, 60, 70),
                     fid = 1)
(aGeom <- gs_polygon(anchor = coords))
visualise(aGeom)

window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
withWindow <- setWindow(x = aGeom, to = window)
visualise(expanded = withWindow)

(aRaster <-  gtRasters$categorical)

# plot several objects together
visualise(aRaster, aGeom)

# give names
visualise(`a raster` = aRaster, `a geom` = aGeom)

# use graphical parameters ...
visualise(aGeom, linecol = "green")

# ... or a theme
visualise(aRaster, theme = setTheme(title = list(plot = FALSE)))

# }

Run the code above in your browser using DataLab