smooth.spline.raster.Rd 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/smoothSpline.R
  3. \name{smooth.spline.raster}
  4. \alias{smooth.spline.raster}
  5. \title{Filter Time Series Imagery with a Cubic Spline}
  6. \usage{
  7. smooth.spline.raster(x, w = NULL, t = NULL, groupYears = TRUE,
  8. timeInfo = orgTime(x), df = 6, outDirPath = "./", ...)
  9. }
  10. \arguments{
  11. \item{x}{\code{RasterBrick} (or \code{RasterStack}) or \code{character} vector
  12. of filenames, sorted 'Vegetation index'.}
  13. \item{w}{\code{RasterBrick} (or \code{RasterStack}) with weighting
  14. information, e.g. derived from \code{\link{makeWeights}}.}
  15. \item{t}{In case of MODIS composite, the corresponding
  16. 'composite_day_of_the_year' \code{RasterBrick} (or \code{RasterStack}).}
  17. \item{groupYears}{\code{logical}. If \code{TRUE}, output files are grouped by
  18. years.}
  19. \item{timeInfo}{Result from \code{\link{orgTime}}.}
  20. \item{df}{\code{numeric}, yearly degree of freedom value passed to
  21. \code{\link{smooth.spline}}. If set as \code{character} (i.e., \code{df = "6"}),
  22. it is not adapted to the time serie length but used as a fixed value (see
  23. Details).}
  24. \item{outDirPath}{Output path, defaults to the current working directory.}
  25. \item{...}{Arguments passed to \code{\link{writeRaster}}. Note that
  26. \code{filename} is created automatically.}
  27. }
  28. \value{
  29. The filtered data and a text file with the dates of the output layers.
  30. }
  31. \description{
  32. This function uses the \code{\link{smooth.spline}} function to filter a
  33. vegetation index time serie of satellite data.
  34. }
  35. \details{
  36. \code{numeric} values of \code{df} (e.g., \code{df = 6)} are treated as
  37. yearly degrees of freedom. Here, the length of the input time series is not
  38. relevant since \code{df} is adapted to it with:
  39. \code{df*('length of _input_ timeserie in days'/365)}. The input length can
  40. differ from the output because of the \code{pillow} argument in
  41. \code{orgTime}.
  42. \code{character} values of \code{df} (e.g., \code{df = "6"}), on the other
  43. hand, are not adopted to the length of the input time series.
  44. Currently tested on MODIS and Landsat data. Using M*D13 data, it is also
  45. possible to use the 'composite_day_of_the_year' layer and the 'VI_Quality'
  46. layer. This function is currently under heavy development and a lot of
  47. changes are expected to come soon.
  48. }
  49. \examples{
  50. \dontrun{
  51. # The full capacity of the following functions is currently avaliable only with M*D13 data.
  52. # !! The function is very new, double check the result!!
  53. # You need to extract the: 'vegetation index', 'VI_Quality layer',
  54. # and 'composite day of the year' layer.
  55. # runGdal(product="MOD13A2",begin="2004340",extent="sicily",end="2006070",
  56. # job="fullCapa",SDSstring="101000000010")
  57. # Afterward extract it to:
  58. options("MODIS_outDirPath")
  59. # the only obligatory dataset is "x" (vegetatino index), get the 'vi' data on the source directory:
  60. path <- paste0(options("MODIS_outDirPath"),"/fullCapa")
  61. vi <- preStack(path=path, pattern="*_NDVI.tif$")
  62. # "orgTime" detects timing information of the input data and generates based on the arguments
  63. # the output date information. For spline functions (in general) the beginning and
  64. # the end of the time series is always problematic.
  65. # So there is the argument "pillow" (default 75 days) that adds
  66. # (if available) some more layers on the two endings.
  67. timeInfo <- orgTime(vi,nDays=16,begin="2005001",end="2005365",pillow=40)
  68. # now re-run "preStack" with two diferences, 'files' (output of the first 'preStack' call)
  69. # and the 'timeInfo'.
  70. # Here only the data needed for the filtering is extractet:
  71. vi <- preStack(files=vi,timeInfo=timeInfo)
  72. smooth.spline.raster(x=vi,timeInfo=timeInfo)
  73. # Filter with weighting and time information:
  74. # if the files are M*D13 you can use also Quality layers and the composite day of the year:
  75. w <- stack(preStack(path=path, pattern="*_VI_Quality.tif$", timeInfo=timeInfo))
  76. w <- makeWeights(w,bitShift=2,bitMask=15,threshold=6)
  77. # you can also pass only the names
  78. t <- preStack(path=path, pattern="*_composite_day_of_the_year.tif$", timeInfo=timeInfo)
  79. smooth.spline.raster(x=vi,w=w,t=t,timeInfo=timeInfo)
  80. }
  81. }
  82. \seealso{
  83. \code{\link{whittaker.raster}}, \code{\link{raster}}.
  84. }
  85. \author{
  86. Matteo Mattiuzzi
  87. }