PLUGPhenAnoRFDMapPLUS: Avocado algorithm - Wall-to-wall map version

View source: R/PLUGPhenAnoRFDPLUS.R

PLUGPhenAnoRFDMapPLUSR Documentation

Avocado algorithm - Wall-to-wall map version

Description

Calculate the Anomaly and their likelihood values (based on the difference between the pixel values and reference vegetation) for a RasterStack

Usage

PLUGPhenAnoRFDMapPLUS(s, phen, dates, h, anop, nCluster, outname, datatype,
  rge)

Arguments

s

RasterStack time series of vegetation index (e.g. NDVI, EVI, NDMI)

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).

nCluster

Numeric. Number of CPU's to be used for the job.

outname

Character vector with the output path and filename with extension or only the filename and extension if work directory was set. More information: See writeRaster

datatype

Character vector that determines the interpretation of values written to disk. More information: See writeRaster

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

RasterStack of nlayers([s]stack*2) containing all anomalies, followed by their likelihoods

Author(s)

Roberto O. Chavez, Mathieu Decuyper

See Also

PLUGPhenAnoRFDPLUS

Examples

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

MDD <- rast(system.file("extdata", "MDD_NDMI_1990_2020.grd", package = "AVOCADO"))
# load dates vector
load(system.file("extdata", "MDD_dates.RData", package = "AVOCADO"))
# load  reference forest shapefile
load(system.file("extdata", "MDDref.RData", 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)
}
PhenKplot(phen, d1, h = 1, xlab = "DOY", ylab = "NDMI", rge = c(0, 10000))

## Anomaly calculation
# checking availiable cores and leave one free
nc1 <- parallel::detectCores() - 1
PLUGPhenAnoRFDMapPLUS(
  s = MDD, dates = MDD_dates, h = 1, phen = phen, anop = c(1:1063),
  nCluster = nc1, outname = "YourDirectory/MDD_AnomalyLikelihood.tif",
  datatype = "INT2S", rge = c(0, 10000)
)
# The output file contains all the anomalies, followed by all their likelihoods
# and thus has twice the number of layers as the input raster stack.

## End(Not run)

MDecuy/AVOCADO documentation built on Oct. 30, 2024, 11:14 a.m.