Description Usage Arguments Details Value Examples
View source: R/senFolderToVar.R
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 of the remote sensing index.
1 2 3 4 5 6 7 8 9 10 |
src |
the path to the folder with the Sentinel-2 multispectral images. |
AppRoot |
directory where the outcoming time series is saved. |
fun |
a |
getStack |
logical argument. If |
overwrite |
logical argument. If |
verbose |
logical argument. If |
resbands |
the resolution of the image being used to compute index,
when the imagery comes from the Senintel-2 " |
... |
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 “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.
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 Sentinel-2 images
senDownSearch(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 = wdir)
# folder with the unzipped images from Sentinel-2
wdir.sen <- file.path(wdir,"Sentinel-2")
wdir.sen.unzip <- file.path(wdir.sen, "unzip")
# mosaic the Sentinel-2 images
senMosaic(wdir.sen.unzip,
AppRoot = wdir.sen,
gutils = TRUE,
out.name = "Navarre")
# path to the folder with the mosaicked images
wdir.sen.navarre <- file.path(wdir.sen, "Navarre")
wdir.sen.var <- file.path(wdir.sen.navarre, "Navarre_Variables")
dir.create(wdir.sen.var)
# generate EVI images of Navarre
senFolderToVar(wdir.sen.navarre,
fun = varEVI,
resbands = c("60m"),
AppRoot = wdir.sen.var)
files.sen.evi <- list.files(file.path(wdir.sen.var,"EVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
img.sen.evi <- lapply(files.sen.evi, raster)
spplot(img.sen.evi[[1]])
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.