The function uses Sen2Cor to manually correct L1C products. Standalone version of sen2cor (version 2.8.0 or 2.5.5) is used.
sen2cor(
l1c_prodlist = NULL,
l1c_dir = NULL,
outdir = NULL,
proc_dir = NA,
tmpdir = NA,
rmtmp = TRUE,
gipp = NULL,
use_dem = NA,
tiles = NULL,
parallel = FALSE,
timeout = 0,
kill_errored = FALSE,
overwrite = FALSE,
.log_message = NA,
.log_output = NA
)
List of L1C product names to be corrected. They can be both product names with full/relative path or only names of SAFE products (in this case, also l1c_dir argument must be provided). SAFE products must be unzipped. Note that, at this stage, all products must be in the same directory (this will be fixed).
Full or relative path of input L1C products.
If NULL (default), l1c_prodlist
must already be a vector of full paths.
Directory where output L2A products will be placed.
If NULL (default), each product is left in the parent directory of l1c_prodlist
.
(optional) Directory where processing is applied.
If NA (default), processing is done in l1c_dir
and output L2A product is
then moved to outdir
, unless l1c_dir
is a subdirectory of a SAMBA mountpoint under Linux:
in this case, L1C input products are copied in a temporary directory
(specified with argument tmpdir
),
processing is done there and then L2A is moved to outdir
.
This is required under Linux systems when l1c_dir
is a subdirectory of
a unit mounted with SAMBA, otherwise Sen2Cor would produce empty L2A products.
(optional) Path where processing is performed if a temporary
working directory is required (see argument proc_dir
). Be sure tmpdir
not to be a SAMBA mountpoint under Linux.
Default is a temporary directory.
If tmpdir
is a non-empty folder, a random subdirectory will be used.
(optional) Logical: should temporary files be removed? (Default: TRUE)
(optional) Ground Image Processing Parameters (GIPP)
to be passed to Sen2Cor.
It is possible to specify both the path of an existing XML file
or a list of parameters in the form parameter_name = "value"
, where
parameter_name
is the name of the parameter as specified in the
XML file (case insensitive), and "value"
is the character value
which the user wants to set
(notice that, in the case the user wants to specify the value NONE
,
both "NONE"
and NA
can be used, but not NULL
, which has the effect
to maintain the value specified in the XML file).
For details about the GIPP parameters, refer to the Sen2Cor documentation
(v. 2.5.5
or 2.8.0:
see the "Schemas of the GIPP file" at the end of each page).
Note: this argument takes effect only in the current execution of
sen2cor()
function.
(optional) Logical: if TRUE, Sen2Cor is set to use a Digital Elevation Model for topographic correction (reflecting what is done for Level-2A SAFE images provided by ESA Hub); if FALSE, it is set not to perform topographic correction (reflecting the current default Sen2Cor behaviour); if NA (default), the option set in the XML GIPP configuration file used by sen2r (stored in the default sen2r settings directory) is respected; in case the user never edited it, the current default setting is not to perform topographic correction.
Notes:
if TRUE, the path used to read or store DEM files
and the online source used to download missing DEM tiles
are respectively the DEM_Directory
and DEM_Reference
parameters
set in the default sen2r GIPP XML file (the user can read them
with the function read_gipp(c("DEM_Directory", "DEM_Reference"))
).
In case one or both these parameters were set to "NONE"
,
a subdirectory "srtm90"
of the default sen2r directory is used as
DEM directory, and/or the
CGIAR SRTM 90m
is set as online source.
To set another directory or reference, use argument gipp
in the form
gipp = list(DEM_Directory = tempdir(), DEM_Reference ="another_reference", ...)
(replacing tempdir()
with the desired path and specifying the online resource).
Currently the default value is NA in order to grant backward compatibility. In a future release of sen2r, the default value will be set to TRUE, so to grant homogeneity between Level-2A products downloaded from ESA Hub and generated using Sen2Cor.
Vector of Sentinel-2 Tile strings (5-length character) to be processed (default: process all the tiles found in the input L1C products).
(optional) Logical: if TRUE, Sen2Cor instances are launched
in parallel using multiple cores; if FALSE (default), they are launched in
series on a single core.
The number of cores is automatically determined; specifying it is also
possible (e.g. parallel = 4
).
Integer value: number of minutes after which killing Sen2Cor if it is still running (default, 0, means that this is never done). This can be useful in case Sen2Cor produced an error without exiting from Python (leaving a standing process running).
Logical: experimental feature allowing killing dead Sen2Cor
processes, so leaving sen2cor()
continuing processing on the remaining
products. Set to TRUE to activate it (default is FALSE).
This experimental feature is available only on Unix systems,
and requires package "tools" to be installed.
This option is not compatible with timeout
(in case both are set,
kill_errored
will be ignored).
Logical value: should existing output L2A products be overwritten? (default: FALSE)
(optional) Internal parameter
(it is used when the function is called by sen2r()
).
(optional) Internal parameter
(it is used when the function is called by sen2r()
).
Vector character with the list ot the output products (being corrected or already existing).
License: GPL 3.0
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. doi:10.1016/j.cageo.2020.104473 , URL: https://sen2r.ranghetti.info/.
if (FALSE) {
# Download an L1C SAFE product
example_s2_list <- s2_list(
spatial_extent = st_sfc(st_point(c(12.0, 44.8)), crs=st_crs(4326)),
tile = "32TQQ",
time_interval = as.Date(c("2017-05-01","2017-07-30"))
)
s2_download(example_s2_list, outdir = tempdir())
# Correct it applying a topographic correction
sen2cor(
names(example_s2_list)[1],
l1c_dir = tempdir(),
outdir = tempdir(),
use_dem = TRUE
)
}