View source: R/ls8FolderToVar.R
ls8FolderToVar | R Documentation |
ls8FolderToVar
computes a remote sensing index from the spectral bands
of a time series of Landsat-8 images. The images are specified by the path to
the folder that stores the imagery (resulting from the lsMosaic
function). The function returns a RasterStack
with a time series of
images of the remote sensing index.
ls8FolderToVar( src, fun, AppRoot, getStack = FALSE, overwrite = FALSE, verbose = FALSE, ... )
src |
path to the folder with the Landsat-8 multispectral image. |
fun |
a |
AppRoot |
the directory of the outcoming time series. |
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
lsMosaic
.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-green-blue (RGB) images must be imported afterwards. Caution! It is mandatory to
use level-2 products to get accurate derived variables.
this function does not return anything, unless getStack = TRUE
which then returns a RasterStack
with the time series of with the
index.
## 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 Landsat-8 images lsDownSearch(satellite = "ls8", username = "username", password = "password", startDate = as.Date("01-01-2018","%d-%m-%Y"), endDate = as.Date("18-01-2018","%d-%m-%Y"), pathrow = list(c(200, 31), c(200, 30)), untar = TRUE, AppRoot = wdir) # folder with the Landsat-8 untared images src.ls8 <-file.path(wdir,"Landsat8") src.ls8.untar <- file.path(src.ls8, "untar") # mosaic the Landsat-8 images lsMosaic(src = src.ls8.untar, AppRoot = src.ls8, out.name = "Navarre", extent = ex.navarre, gutils = TRUE) # path to the folder with mosaicked images src.ls8.navarre <- file.path(src.ls8, "Navarre") # generate NDVI images of Navarre src.ls8.var <- file.path(src.ls8, "Navarre_Variables") dir.create(src.ls8.var) ls8FolderToVar(src.ls8.navarre, fun = varNDVI, AppRoot = src.ls8.var, overwrite = TRUE) files.ls8.ndvi <- list.files(file.path(src.ls8.var,"NDVI"), pattern = "\\.tif$", full.names = TRUE, recursive = TRUE) img.ls8.ndvi <- raster(files.ls8.ndvi[1]) spplot(img.ls8.ndvi) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.