bfmPlot: ggplot bfastmonitor

Description Usage Arguments Value Author(s) See Also Examples

Description

Generate a ggplot object from a (list of) bfastmonitor object(s)

Usage

1
2
3
4
bfmPlot(bfm, plotlabs = NULL, ncols = 1, rescale = 1, ylab = "response",
  displayMagn = FALSE, magn_ypos = 0.3, magn_xoffset = -0.45,
  magn_digits = 3, displayTrend = TRUE, displayResiduals = c("none",
  "all", "monperiod", "history"), type = "irregular")

Arguments

bfm

Object of type bfastmonitor or a list of such objects

plotlabs

Character. Optional: vector of facet plot lables. These should correspond to bfm

ncols

Numeric. Number of columns in plot

rescale

Numeric. Factor by which to rescale data

ylab

Character. y-axis label

displayMagn

Logical. Display magnitude on plot? See bfastmonitor for more information

magn_ypos

Numeric. Vertical position of magnitude label on plot (relative to y-range)

magn_xoffset

Numeric. Horizontal offset of magnitude label relative to the start of the monitoring period (vertical black line)

magn_digits

Numeric. Number of digits to round magnitude

displayResiduals

Character. Section of the plot where residuals should be highlighted. Defaults to "none" - no residuals highlighted.

type

Character. Type of time series. Can be either "irregular" (Landsat-type) or "16-day" (MODIS-type). See bfastts for more information.

displayTend

Logical. Display trend component of history model as dotted blue line?

Value

ggplot object (see ggplot).

Author(s)

Ben DeVries

See Also

bfmPredict

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# adapted from help page of bfastmonitor

library(bfast)
library(ggplot2)

NDVIa <- as.ts(zoo(som$NDVI.a, som$Time))
plot(NDVIa)
## apply the bfast monitor function on the data
## start of the monitoring period is c(2010, 13)
## and the ROC method is used as a method to automatically identify a stable history
mona1 <- bfastmonitor(NDVIa, start = c(2010, 13), formula = response ~ harmon, order = 3)
class(mona1)

# regular plot
plot(mona1)
# ggplot of the same
p <- bfmPlot(mona1)
p

## the advantage of ggplot is that is is object based
## additional layers can simply be added
# change to black/white background
p2 <- p + theme_bw()
p2

## combine several bfastmonitor objects into one facet plot
mona2 <- bfastmonitor(NDVIa, start = c(2010, 13), formula = response~harmon, order=2)
mona3 <- bfastmonitor(NDVIa, start = c(2010, 13), formula = response~harmon, order=1)
p3 <- bfmPlot(list(mona1, mona2, mona3), plotlabs = c("order = 3", "order = 2", "order = 1")) + theme_bw()
p3

# it's not necessary to show the trend when there is none
p4 <- bfmPlot(list(mona1, mona2, mona3),
plotlabs = c("order = 3", "order = 2", "order = 1"), displayTrend = FALSE) + theme_bw()
p4

# compare land cover time series
data(tura_ts1) # cropland pixel
data(tura_ts2) # forest pixel
data(tura_ts3) # converstion of forest to cropland

x <- list(tura_ts1, tura_ts2, tura_ts3)
y <- lapply(x, FUN=function(z) bfastts(z, dates = time2date(time(z)), type = "irregular"))
bfm <- lapply(y, FUN=function(z) bfastmonitor(z, start = c(2008, 1), formula = response~harmon, order = 1, history = "all"))
p5 <- bfmPlot(bfm, displayResiduals = "monperiod", plotlabs = c("cropland", "forest", "forest to cropland"), displayTrend = FALSE) + theme_bw()
p5 <- p5 + labs(y = "NDVI")
p5

# sequential monitoring periods for forest disturbance monitoring
# convert to 'regular' bfast time series
x <- bfastts(tura_ts3, dates = time2date(time(tura_ts1)), type = "irregular")
years <- c(2005:2009)
bfm <- lapply(years, FUN=function(z) bfastmonitor(window(x, end = c(z + 1, 1)), start = c(z, 1), history = "all", formula = response ~ harmon, order = 1))
## returns a list of bfastmonitor objects

# show all results with change magnitudes for each monitoring period
# also show residuals in the monitoring period only
p6 <- bfmPlot(bfm, plotlabs = years, displayTrend = FALSE, displayMagn = TRUE, displayResiduals = "monperiod") + theme_bw()
p6

bendv/bfastPlot documentation built on May 12, 2019, 10:58 a.m.