Description Usage Arguments Details Value Examples
View source: R/modFolderToVar.R
modFolderToVar
computes a remote sensing index from the spectral bands
of a time series of MODIS images. The images are specified by the path to
the folder that stores the imagery (resulting from the modMosaic
function). The function returns a RasterStack
with a time series of
images of the remote sensing index.
1 2 3 4 5 6 7 8 9 | modFolderToVar(
src,
AppRoot,
fun,
getStack = FALSE,
overwrite = FALSE,
verbose = FALSE,
...
)
|
src |
path to the folder with the MODIS multispectral images. |
AppRoot |
the directory of the outcoming time series. |
fun |
a |
getStack |
logical argument. If |
overwrite |
logical argument. If |
verbose |
logical argument. If |
... |
arguments for nested functions.
|
The function requires the definition of the src
and fun
arguments. The src
is usually the path resulting from
modMosaic
. The fun
argument can be any function from
this package beginning with “var” (varNDVI
, varEVI
,
etc.). Custom functions can also be implemented. If fun = varRGB
, then
the argument getStack
must be equal to FALSE
and the
red-gree-blue (RGB) images must be imported afterwards.
this function does not return anything, unless getStack = TRUE
which then returns a RasterStack
with the time series of with the
index.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ## Not run:
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
# download MOD09 images
modDownSearch(product = "MOD09GA",
startDate = as.Date("01-01-2018", "%d-%m-%Y"),
endDate = as.Date("03-01-2018", "%d-%m-%Y"),
username = "username",
password = "password",
AppRoot = wdir, # output folder for tif images
extract.tif = TRUE,
collection = 6,
extent = ex.navarre)
# assign wdir.mod as the output folder from modMosaic
wdir.mod <- file.path(wdir, "Modis", "MOD09GA") # output directory
wdir.mod.tif <- file.path(wdir.mod, "tif") # input directory
# mosaic the MODIS images
modMosaic(wdir.mod.tif,
AppRoot = wdir.mod,
out.name = "Navarre")
# path to the folder with the mosaicked images
wdir.mod.navarre <- file.path(wdir.mod, "Navarre")
# generate NDVI images of Navarre
wdir.mod.var <- file.path(wdir.mod, "Variables")
dir.create(wdir.mod.var)
modFolderToVar(src = wdir.mod.navarre,
fun = varEVI,
scfun = getRGISToolsOpt("MOD09SCL"),
AppRoot = wdir.mod.var,
overwrite = TRUE)
# import mosaicked images (.tif) to the environment in `R'
files.mod.evi <- list.files(file.path(wdir.mod.var,"EVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
img.mod.evi <- lapply(files.mod.evi,raster)
spplot(img.mod.evi[[1]],at=seq(-1,2.5))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.