
Last chance! 50% off unlimited learning
Sale ends in
senFolderToVar
computes a remote sensing index from the spectral bands
of a time series of Sentinel-2 images. The images are specified by the path to
the folder that stores the imagery (resulting from the senMosaic
function). The function returns a RasterStack
with a time series of
images with the index.
senFolderToVar(src, AppRoot, fun, getStack = FALSE, overwrite = FALSE,
verbose = FALSE, resbands = c("10m", "20m", "60m"), ...)
the path to the folder with the Sentinel-2 multispectral images.
directory where the outcoming time series is saved.
a function
that computes the remote sensing index.
logical argument. If TRUE
, returns the time series of
images as a RasterStack
, otherwise the images are saved in the Hard
Drive Device (HDD).
logical argument. If TRUE
, overwrites the existing
images with the same name.
logical argument. If TRUE
, the function prints the
running steps and warnings.
the resolution of the image being used to compute index,
when the imagery comes from the Senintel-2 "S2MSI2A
" product. By
default, all resolutions (10m, 20m, and 60m) are used.
arguments for nested functions.
The function requires the definition of the src
and fun
arguments. The src
is usually the path resulting from
senMosaic
. The fun
argument can be any function from
this package beginning with <U+201C>var<U+201D> (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.
# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
src <- paste0(tempdir(),"/Path_for_downloading_folder")
print(src)
# download Sentinel-2 images
senDownload(startDate = as.Date("2018210","%Y%j"),
endDate = as.Date("2018218","%Y%j"),
platform = "Sentinel-2",
extent = ex.navarre,
product = "S2MSI1C",
pathrow = c("R094"),
username = "username",
password = "password",
AppRoot = src)
# folder with the unzipped images from Sentinel-2
src.sen <- file.path(src,"Sentinel-2")
src.unzip <- file.path(src.sen, "unzip")
# mosaic the Sentinel-2 images
senMosaic(src.unzip,
AppRoot = src.sen,
gutils = TRUE,
out.name = "Navarre")
# path to the folder with the mosaicked images
src2 <- file.path(src.sen, "Navarre")
src3 <- file.path(src.sen, "Navarre_Variables")
dir.create(src3)
# generate EVI images of Navarre
senFolderToVar(src2,
fun = varEVI,
resbands = c("60m"),
AppRoot = src3)
flist <- list.files(file.path(src3,"EVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
files.raster <- lapply(flist, raster)
spplot(files.raster[[1]])
# }
Run the code above in your browser using DataLab