whittaker.raster.Rd 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/whittaker.R
  3. \name{whittaker.raster}
  4. \alias{whittaker.raster}
  5. \title{Filter Vegetation Index with Modified Whittaker Approach}
  6. \usage{
  7. whittaker.raster(vi, w = NULL, t = NULL, timeInfo = orgTime(vi),
  8. lambda = 5000, nIter = 3, outputAs = "single", collapse = FALSE,
  9. prefixSuffix = c("MCD", "ndvi"), outDirPath = ".",
  10. outlierThreshold = NULL, mergeDoyFun = "max", ...)
  11. }
  12. \arguments{
  13. \item{vi}{\code{Raster*} or \code{character} filenames, sorted VI. Use
  14. \code{\link{preStack}} functionality to ensure the right input.}
  15. \item{w}{\code{Raster*} or \code{character} filenames. In case of MODIS
  16. composite, the sorted 'VI_Quality' layers.}
  17. \item{t}{\code{Raster*} or \code{character} filenames. In case of MODIS
  18. composite, the sorted 'composite_day_of_the_year' layers. If missing, the
  19. date is determined using \code{timeInfo}.}
  20. \item{timeInfo}{Output from \code{\link{orgTime}}.}
  21. \item{lambda}{\code{character} or \code{integer}. Yearly lambda value passed
  22. to \code{\link{whit2}}. If set as \code{character} (i.e.,
  23. \code{lambda = "600"}), it is not adapted to the time serie length, but used
  24. as a fixed value (see Details). High values = stiff/rigid spline.}
  25. \item{nIter}{\code{integer}. Number of iteration for the upper envelope
  26. fitting.}
  27. \item{outputAs}{\code{character}, organisation of output files.
  28. \code{"single"} (default) means each date one \code{RasterLayer};
  29. \code{"yearly"} a \code{RasterBrick} for each year, and \code{"one"} one
  30. \code{RasterBrick} for the entire time series.}
  31. \item{collapse}{\code{logical}. Collapse input data of multiple years into
  32. one single year before filtering.}
  33. \item{prefixSuffix}{\code{character}, file naming. Names are composed
  34. dot-separated: \code{paste0(prefixSuffix[1], "YYYDDD", lambda,
  35. refixSuffix[2], ".defaultFileExtension")}.}
  36. \item{outDirPath}{\code{character}, output path. Defaults to the current
  37. working directory.}
  38. \item{outlierThreshold}{\code{numeric} in the same unit as \code{vi}, used
  39. for outlier removal (see Details).}
  40. \item{mergeDoyFun}{Especially when using \code{collapse = TRUE}, multiple
  41. measurements for one day can be present. Here you can choose how those values
  42. are merged to one single value: \code{"max"} uses the highest value,
  43. \code{"mean"} or \code{"weighted.mean"} use the \code{\link{mean}} if no
  44. weighting \code{"w"} is available, and \code{\link{weighted.mean}} if it is.}
  45. \item{...}{Arguments passed to \code{\link{writeRaster}} (except for
  46. \code{filename}).}
  47. }
  48. \value{
  49. A Whittaker-smoothened \code{RasterStack}.
  50. }
  51. \description{
  52. Use a modified Whittaker filter function (see References) from package
  53. \strong{ptw} to filter a vegetation index (VI) time serie of satellite data.
  54. }
  55. \details{
  56. The argument \code{lambda} is passed to \code{MODIS:::miwhitatzb1}. You can
  57. set it as yearly \code{lambda}, which means that it doesn't matter how long
  58. the input time serie is because \code{lambda} is adapted to it with:
  59. \code{lambda*('length of input timeserie in days'/365)}. The input length can
  60. differ from the output because of the \code{pillow} argument in
  61. \code{orgTime}. But it can also be set as \code{character} (i.e.,
  62. \code{lambda = "1000"}). In this case, the adaption to the time series length
  63. is not performed.\cr
  64. }
  65. \note{
  66. Currently tested on MODIS and Landsat data. Using M*D13, it is also possible
  67. to use the 'composite_day_of_the_year' and the 'VI_Quality' layers. Note that
  68. this function is currently under heavy development.
  69. }
  70. \examples{
  71. \dontrun{
  72. # The following function will download bit more than 1 year of MOD13A1 (~180mB) and therefore
  73. # take while to execute! Data will be downloaded to options("MODIS_localArcPath") and processed
  74. # to 'paste0(options("MODIS_outDirPath"),"fullCapa")'
  75. # You need to extract: 'vegetation index', 'VI_Quality layer', and 'composite day of the year',
  76. # this is expressed by the argument 'SDSstring'
  77. runGdal(product="MOD13A2",begin="2004340",extent="irland",end="2006020", job="fullCapa",
  78. SDSstring="101000000010")
  79. path <- paste0(options("MODIS_outDirPath"),"fullCapa")
  80. # the only obligatory dataset is the vegetatino index
  81. # get the 'vi' data in the source directory:
  82. vi <- preStack(path=path, pattern="*_NDVI.tif$")
  83. # "orgTime" detects timing information of the input data and generates based on the arguments
  84. # the output date information.
  85. # For spline functions (in general) the beginning and the end of the time series
  86. # is always problematic. So there is the argument "pillow" (default 75 days) that adds
  87. # (if available) some more layers on the two endings.
  88. timeInfo <- orgTime(vi,nDays=16,begin="2005001",end="2005365",pillow=40)
  89. # now re-run "preStack" with two differences, 'files' (output of the first 'preStack' call)
  90. # and the 'timeInfo'
  91. # Here only the data needed for the filtering is extracted:
  92. vi <- preStack(files=vi,timeInfo=timeInfo)
  93. whittaker.raster(vi,timeInfo=timeInfo,lambda=5000)
  94. # if the files are M*D13 you can use also Quality layers and the composite day of the year:
  95. wt <- preStack(path=path, pattern="*_VI_Quality.tif$", timeInfo=timeInfo)
  96. # can also be already stacked:
  97. inT <- preStack(path=path, pattern="*_composite_day_of_the_year.tif$", timeInfo=timeInfo)
  98. whittaker.raster(vi=vi, wt=wt, inT=inT, timeInfo=timeInfo, lambda=5000, overwrite=TRUE)
  99. }
  100. }
  101. \references{
  102. Modified Whittaker smoother, according to Atzberger & Eilers 2011
  103. International Journal of Digital Earth 4(5):365-386.\cr
  104. Implementation in R: Agustin Lobo 2012
  105. }
  106. \seealso{
  107. \code{\link{smooth.spline.raster}}, \code{\link{raster}}.
  108. }
  109. \author{
  110. Matteo Mattiuzzi and Agustin Lobo
  111. }