Learn R Programming

phenofit (version 0.2.7)

plot_phenofit: plot_phenofit

Description

plot_phenofit

Usage

plot_phenofit(
  d_fit,
  seasons,
  d_obs = NULL,
  title = NULL,
  title.xlab = "Time",
  title.ylab = "Vegetation Index",
  font.size = 14,
  theme = NULL,
  cex = 2,
  shape = "point",
  angle = 30,
  show.legend = TRUE
)

Arguments

d_fit

data.frame of curve fittings returned by get_fitting().

seasons

Growing season dividing object returned by season() and season_mov().

d_obs

data.frame of original vegetation time series, with the columns of t, y and QC_flag. If not specified, it will be determined from d_fit.

title

String, title of figure.

title.xlab, title.ylab

String, title of xlab and ylab.

font.size

Font size of axis.text

theme

ggplot theme to be applied

cex

point size for VI observation.

shape

the shape of input VI observation? line or point

angle

text.x angle

show.legend

Boolean

Examples

Run this code
# NOT RUN {
library(phenofit)
data("MOD13A1")

df <- tidy_MOD13.gee(MOD13A1$dt)
st <- MOD13A1$st

date_start <- as.Date('2013-01-01')
date_end   <- as.Date('2016-12-31')

sitename <- 'CA-NS6' # df$site[1]
d     <- df[site == sitename & (date >= date_start & date <= date_end), ]
sp    <- st[site == sitename, ]
south <- sp$lat < 0
nptperyear <- 23

# global parameter
IsPlot = TRUE
print  = FALSE
ypeak_min  = 0.05
wFUN = wTSM

# add one year in head and tail
dnew     <- add_HeadTail(d, south = south, nptperyear = nptperyear) 
INPUT    <- check_input(dnew$t, dnew$y, dnew$w, QC_flag = dnew$QC_flag,
     nptperyear = nptperyear, south = south, 
     maxgap = nptperyear/4, alpha = 0.02, wmin = 0.2)
# Rough fitting and growing season dividing
brks2 <- season_mov(INPUT,
    rFUN = smooth_wWHIT, wFUN = wFUN,
    plotdat = d, IsPlot = IsPlot, print = FALSE, IsPlot.OnlyBad = FALSE)
# Fine fitting
fit <- curvefits(
    INPUT, brks2,
    methods = c("AG", "Beck", "Elmore", "Zhang"), #,"klos", "Gu"
    wFUN = wFUN,
    nextend = 2, maxExtendMonth = 2, minExtendMonth = 1, minPercValid = 0.2,
    print = TRUE, verbose = FALSE)
## visualization
df_fit <- get_fitting(fit)
g <- plot_phenofit(df_fit, brks2)
grid::grid.newpage(); grid::grid.draw(g)
# }

Run the code above in your browser using DataLab