ggmap2: Create map(s) of one raster layer or a raster stack

View source: R/ggmap2.R

ggmap2R Documentation

Create map(s) of one raster layer or a raster stack

Description

Read a global raster layer or raster stack and plot on a map

Usage

ggmap2(
  data,
  name = "",
  split = FALSE,
  trans = "identity",
  facet_grid = FALSE,
  crop = TRUE,
  grid = FALSE,
  colours = colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow",
    "#FF7F00", "red", "#7F0000"))(255),
  varnames = NA,
  subnames = "",
  outline = NA,
  extent = NA,
  ncol = 2,
  long = FALSE,
  country = TRUE,
  save = FALSE,
  filename = "Rplots.pdf"
)

Arguments

data

raster layer, raster stack or dataframe

name

character, name of legend

split

logical, should multiple plots have individual legends or not

trans

transform data

facet_grid

logical, default to FALSE, if TRUE facet_grid is used for plotting

crop

logical, default to TRUE, not implemented right now

grid

logical, default to FALSE, if TRUE a grid is added to the plot

colours

specify colourPalette used for ggplot2::scale_fill_gradientn()

varnames

character vector with names of data

subnames

character vector with subnames of data

outline

default is NA

extent

defaults to NA

ncol

specify number of columns for plotting with facet_wrap or ..., not needed if facet_grid is TRUE.

long

defaults to FALSE. Specify if data is in long format or not.

country

defaults to TRUE. Add country outline to plot.

save

defaults to FALSE. Specify if plot should be written to file.

filename

If save=TRUE you can specify the filename of your plot here

Value

ggplot2 object

Examples

# Load raster library
library(raster)
# Create data
r <- raster(nrow=90, ncol=180)
r <- setValues(r, rnorm(ncell(r), 0, 1))
#Create plots
ggmap2(r, name="Single", split=FALSE, ncol=1)
ggmap2(r, name="Single", split=FALSE, ncol=1, extent=c(-20, 70, -50, 80))

RS-eco/ggmap2 documentation built on Dec. 7, 2022, 2:02 a.m.