PhenRef2d: Avocado algorithm - calculate likelihood of...

View source: R/PLUGPhenAnoRFDPLUS.R

PhenRef2dR Documentation

Avocado algorithm - calculate likelihood of vegetation-index–time space for reference vegetation

Description

Calculate the cumulative density distribution and their likelihood values based on reference vegetation - input for Wall-to-wall map version (i.e. PLUGPhenAnoRFDPLUS function)

Usage

PhenRef2d(phen, dates, h, anop, rge)

Arguments

phen

Numeric vector with the values of the reference vegetation

dates

A date vector. The number of dates must be equal to the number of values of time series.

h

Numeric. Geographic hemisphere to define the starting date of the growing season. h=1 Northern Hemisphere; h=2 Southern Hemisphere.

anop

Numeric vector with the number of values that are in x. For those values the anomalies and likelihoods will be calculated based on the phen. For example a time series has 450 values, so anop=c(1:450).

rge

A vector containing minimum and maximum values of the response variable used in the analysis. We suggest the use of theoretically based limits. For example in the case of MODIS NDVI or EVI, it ranges from 0 to 10,000, so rge =c(0,10000)

Value

List which contains cumulative bivariate density distribution (cumDensity), and maximum likelihood of the vegetation-index–time space (MAXY)

Author(s)

Roberto O. Chavez, Mathieu Decuyper

See Also

PLUGPhenAnoRFDMapPLUS PLUGPhenAnoRFDPLUS

Examples

## Not run: 
# Loading raster data
library(terra)
library(npphen)

MDD <- rast(system.file("extdata", "MDD_NDMI_1990_2020.tif", package = "AVOCADO"))
# load dates vector
load(system.file("extdata", "MDD_dates.RData", package = "AVOCADO"))
# load  reference forest shapefile
MDDref <- vect(system.file("extdata", "MDDref.gpkg", package = "AVOCADO"))
# Create the reference curve
ref.ext <- ext(MDDref)
ref.brick <- crop(MDD, ref.ext)
fin <- nrow(ref.brick) * ncol(ref.brick)
phen <- as.numeric(terra::extract(ref.brick, 1))
d1 <- MDD_dates
for (i in 2:fin) {
  pp <- as.numeric(terra::extract(ref.brick, i))
  phen <- c(phen, pp)
  d1 <- c(d1, MDD_dates)
}
MDD_fref <- PhenRef2d(phen, d1, h = 1, anop = c(1:1063), rge = c(0, 10000))

# plot reference curve + probabilities (same result as using PhenKplot())
image(MDD_fref$x, MDD_fref$y, MDD_fref$cumDensity, xlab = "DOY", ylab = "NMDI", 
font.lab = 2, breaks = c(0, 0.5, 0.75, 0.9, 0.95), col = grDevices::heat.colors(n = 4, alpha = 0.6))
contour(MDD_fref$x, MDD_fref$y, MDD_fref$cumDensity, levels = c(0, 0.5, 0.75, 0.9, 0.95), add = T, col = grDevices::grey(0.25), labcex = 1)
lines(seq(1, 365), MDD_fref$MAXY, lwd = 3, col = "dark red")


## End(Not run)


MDecuy/AVOCADO documentation built on April 14, 2025, 5:30 a.m.