Image: Image Panels

Description Usage Arguments Value Author(s) See Also Examples

Description

Creates an image panel to visualize data in 4, 3 or 2 dimensional arrays (e.g., space-time data). The function returns a ggplot2 object, which can be modified using ggplot2 (and/or grid) syntax.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Image(
  x = NULL,
  zlim = range(x, na.rm = TRUE),
  col = fields::tim.colors(1000),
  theme = TRUE,
  guides = TRUE,
  na.value = "black",
  panelsByrow = TRUE,
  asRaster = TRUE,
  xlab = "",
  ylab = "",
  colbarTitle = "",
  ...
)

Arguments

x

Numeric array with 4, 3, or 2 dimensions containing the data to be plotted.

zlim

Numeric vector of length 2. Gives the upper and lower bound of the plotted values.

col

Vector of colors.

theme

Logical vector of length one. Should the ggplot2 theme be modified?

guides

Logical vector of length one. Should ggplot2 guides be modified?

na.value

Vector of length one. The color to be used for NA values.

panelsByrow

Logical vector of length one. Indicates the ordering of the panels.

asRaster

Logical vector of length one. If TRUE, the ordering of the pixel within images is similar to the plot method of the raster package. Otherwise, the ordering is similar to image.

xlab

Character vector (or expression) of length one giving the x-axis label.

ylab

Character vector (or expression) of length one giving the y-axis label.

colbarTitle

Character vector (or expression) of length one giving the colorbar label.

...

Additional arguments are passed to ggplot.

Value

Object (plot) of class c("gg", "ggplot2").

Author(s)

Florian Gerber, flora.fauna.gerber@gmail.com.

See Also

ndvi, ggplot2.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library("abind")
t1 <- array(rep(c(1,0), each = 5), c(5,5))
t1[5,3] <- 2 
t2 <- abind(t1, t1, along = 3)
t3 <- abind(t2, t2, along = 4)
Image(t1)
Image(t2)
Image(t3)

## Not run: 
Image(ndvi)

p1 <- Image(ndvi, colbarTitle = "NDVI", xlab = "Year", ylab = "DOY",
            panelsByrow  = FALSE)
p1

p2 <- Image(ndvi[,,3,2], na.value = "white", colbarTitle = "NDVI") +
      theme(strip.text.x = element_blank(),
            strip.text.y = element_blank(),
            panel.border = element_rect(fill = NA, size = 1))
p2

## place modified color bar left
p2 + guides(fill = guide_colorbar(title = "NDVI", 
                                  barwidth = 1,
                                  barheight = 20,
                                  label.position = "right", 
                                  legend.position = c(0, 0))) +
     theme(legend.position = "right")

## place color bar at bottom
p2 + guides(fill = guide_colorbar(title = "NDVI", 
                                  barwidth = 7,
                                  barheight = .7,
                                  label.position = "bottom", 
                                  legend.position = c(0, 0)),
                                  direction = "horizontal") +
     theme(legend.position = "bottom")

## End(Not run)

Example output

Loading required package: ggplot2
--> See ?Gapfill and https://doi.org/10.1109/TGRS.2017.2785240 <--

gapfill documentation built on Feb. 12, 2021, 5:06 p.m.