Is there a way to calculate mean annual NDVI and mean annual EVI from the time series MODIS images (2000 - 2016). I have gridded data downloaded to the local drive. Planning to use R for this work.
As described in a previous thread, the most accurate way to create temporal composites from raw 16-day MODIS vegetation indices (VI) layers is to make use of the accompanying 'composite_day_of_the_year' (DOY) scientific data sets. Since the last image from a particular year (eg 2015) might already contain some pixels from the following year (eg 2016), such an approach ensures that only valid pixels (ie actually originating from 2015) are included in the calculation.
The creation of yearly value composites has been made available through MODIS_1.1.0. Simply install the package and have a look at the 'Examples' section in
?temporalComposite. The function requires you to specify VI and DOY layers as either 'character' file names or 'Raster*' objects. Starting from data download and extraction), the creation of yearly NDVI (and similarly EVI) mean value composites would go as follows:
# devtools::install_github("MatMatt/MODIS", ref = "develop") library(MODIS) library(mapview) ## download and extract sample data frc <- as(subset(franconia, district == "Mittelfranken"), "Spatial") tfs <- runGdal("MOD13A1", begin = "2015001", end = "2016366", extent = frc, job = "temporalComposite", SDSstring = "100000000010") ## separate ndvi and doy layers ndvi <- sapply(tfs[], "[[", 1) cdoy <- sapply(tfs[], "[[", 2) ## create yearly mean value composites ymvc <- temporalComposite(ndvi, cdoy, interval = "year", fun = mean)
raster package, if you already have a
RasterStack with time written to the z dimension (see
setZ), you can simply use
library(raster) library(lubridate) zApply(b, by = year, fun = mean)