Learn R Programming

inlabru (version 2.11.1)

gg.RasterLayer: Geom for RasterLayer objects

Description

This function takes a RasterLayer object, converts it into a SpatialPixelsDataFrame and uses geom_tile to plot the data.

Usage

# S3 method for RasterLayer
gg(
  data,
  mapping = ggplot2::aes(x = .data[["x"]], y = .data[["y"]], fill = .data[["layer"]]),
  ...
)

Value

An object returned by geom_tile

Arguments

data

A RasterLayer object.

mapping

aesthetic mappings created by aes. These are passed on to geom_tile.

...

Arguments passed on to geom_tile.

Details

This function requires the raster and ggplot2 packages.

See Also

Other geomes for Raster data: gg(), gm()

Examples

Run this code
if (FALSE) {
# Some features require the raster and spatstat.data packages.
if (require("spatstat.data", quietly = TRUE) &&
  require("raster", quietly = TRUE) &&
  require("ggplot2", quietly = TRUE)) {
  # Load Gorilla data
  data("gorillas", package = "spatstat.data")

  # Convert elevation covariate to RasterLayer

  elev <- as(gorillas.extra$elevation, "RasterLayer")

  # Plot the elevation

  ggplot() +
    gg(elev)
}
}

Run the code above in your browser using DataLab