View source: R/s2_calcindices.R
s2_calcindices | R Documentation |
Create maps of a set of spectral indices. Since
gdal_calc.py
is used to perform computations, output files
are physical rasters (no output VRT is allowed).
s2_calcindices(
infiles,
indices,
outdir = ".",
parameters = NULL,
source = c("TOA", "BOA"),
format = NA,
subdirs = NA,
tmpdir = NA,
compress = "DEFLATE",
bigtiff = FALSE,
dataType = "Int16",
scaleFactor = NA,
proc_mode = "raster",
parallel = FALSE,
overwrite = FALSE,
.log_message = NA,
.log_output = NA
)
infiles |
A vector of input filenames. Input files are paths of BOA (or TOA) products already converted from SAFE format to a format managed by GDAL (use s2_translate to do it); their names must be in the sen2r naming convention (safe_shortname). |
indices |
Character vector with the names of the required indices. Values should be included in names corresponding to the Abbreviations of the following indices: IDB. |
outdir |
(optional) Full name of the output directory where
the files should be created (default: current directory).
|
parameters |
(optional) Values of index parameters. This variable
must be a named list, in which each element is a list of parameters,
i.e.:
|
source |
(optional) Vector with the products from which computing
the indices. It can be |
format |
(optional) Format of the output file (in a format recognised by GDAL). Default is the same format of input images (or "GTiff" in case of VRT input images). |
subdirs |
(optional) Logical: if TRUE, different indices are
placed in separated |
tmpdir |
(optional) Path where intermediate files (GTiff) will be
created in case |
compress |
(optional) In the case a GTiff format is present, the compression indicated with this parameter is used. |
bigtiff |
(optional) Logical: if TRUE, the creation of a BigTIFF is forced (default is FALSE). This option is used only in the case a GTiff format was chosen. |
dataType |
(optional) Numeric datatype of the output rasters.
if "Float32" or "Float64" is chosen, numeric values are not rescaled;
if |
scaleFactor |
(optional) Scale factor for output values when an integer
datatype is chosen (default values are 10000 for |
proc_mode |
(optional) Character: if
|
parallel |
(optional) Logical: if TRUE, the function is run using parallel
processing, to speed-up the computation for large rasters.
The number of cores is automatically determined; specifying it is also
possible (e.g. |
overwrite |
Logical value: should existing output files be overwritten? (default: FALSE) |
.log_message |
(optional) Internal parameter
(it is used when the function is called by |
.log_output |
(optional) Internal parameter
(it is used when the function is called by |
A vector with the names of the created products.
License: GPL 3.0
Luigi Ranghetti, phD (2020)
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473")}, URL: https://sen2r.ranghetti.info/.
# Define file names
ex_in <- system.file(
"extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif",
package = "sen2r"
)
# Run function
ex_out <- s2_calcindices(
infiles = ex_in,
indices = "EVI",
outdir = tempdir(),
dataType = "Float32"
)
ex_out
# Show output
oldpar <- par(mfrow = c(1,2), mar = rep(0,4))
image(stars::read_stars(ex_in), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
par(mar = rep(2/3,4))
image(stars::read_stars(ex_out), useRaster = TRUE)
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.