if (FALSE) {
# The full capacity of the following functions is currently available only
# with M*D13 data.
# !! The function is very new, double check the result!!
# You need to extract the: 'vegetation index', 'VI_Quality layer',
# and 'composite day of the year' layer.
# runGdal(product="MOD13A2",begin="2004340",extent="sicily",end="2006070",
# job="fullCapa",SDSstring="101000000010")
# Afterward extract it to:
options("MODIS_outDirPath")
# the only obligatory dataset is "x" (vegetatino index), get the 'vi' data on
# the source directory:
path <- paste0(options("MODIS_outDirPath"),"/fullCapa")
vi <- preStack(path=path, pattern="*_NDVI.tif$")
# `orgTime()` detects timing information of the input data and generates
# based on the arguments the output date information. For spline functions
# (in general) the start and end of the time series is always problematic.
# So there is the argument "pillow" (default 75 days) that adds
# (if available) some more layers on the two endings.
timeInfo <- orgTime(vi,nDays=16,begin="2005001",end="2005365",pillow=40)
# now re-run "preStack" with two differences, 'files' (output of the first
# `preStack()` call) and the 'timeInfo'.
# Here only the data needed for the filtering is extracted:
vi <- preStack(files=vi,timeInfo=timeInfo)
smooth.spline.raster(x=vi,timeInfo=timeInfo)
# Filter with weighting and time information:
# if the files are M*D13 you can use also use quality layers and the
# composite day of the year:
w <- stack(preStack(path=path, pattern="*_VI_Quality.tif$", timeInfo=timeInfo))
w <- makeWeights(w,bitShift=2,bitMask=15,threshold=6)
# you can also pass only the names
t <- preStack(path=path, pattern="*_composite_day_of_the_year.tif$", timeInfo=timeInfo)
smooth.spline.raster(x=vi,w=w,t=t,timeInfo=timeInfo)
}
Run the code above in your browser using DataLab