---
title: "Output file structure"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Output file structure}
  %\VignetteEngine{knitr::knitr}
  %\usepackage[UTF-8]{inputenc}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

[Products](#products) generated using 
<span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
functions follows a precise [naming convention](#naming-convention),
and are organised within a customisable [folder structure](#folder-structure).


## Products

Currently, <span style="color:#5793dd;vertical-align:top;font-size:90%;font-weight:normal;">sen</span><span style="color:#6a7077;vertical-align:baseline;font-size:115%;font-weight:bolder;">2</span><span style="color:#2f66d5;vertical-align:baseline;font-size:90%;font-weight:bold;">r</span>
can be used to generate the following products:

1. [surface reflectances](#surface-reflectances) (<span style='font-family:monospace;color:#FF6611;'>TOA</span>
    or <span style='font-family:monospace;color:#FF6611;'>BOA</span>);
2. [Accessory layers](#accessory-layers)
    (<span style='font-family:monospace;color:#FF6611;'>SCL</span>,
    <span style='font-family:monospace;color:#FF6611;'>CLD</span>,
    <span style='font-family:monospace;color:#FF6611;'>SNW</span>,
    <span style='font-family:monospace;color:#FF6611;'>WVP</span>,
    <span style='font-family:monospace;color:#FF6611;'>AOT</span>);
3. [Spectral indices](#spectral-indices);
4. true or false colour [RGB images](#rgb-colour-images).

### Surface reflectances
<span style='font-family:monospace;color:#FF6611;'>TOA</span>
(Top Of Atmosphere) and 
<span style='font-family:monospace;color:#FF6611;'>BOA</span>
(Bottom Of Atmosphere) surface reflectances are multiband rasters
containing 12 (<span style='font-family:monospace;color:#FF6611;'>TOA</span>)
or 11 (<span style='font-family:monospace;color:#FF6611;'>BOA</span>) bands,
here listed:

1. Band 1 -- Aerosol (443 nm)
2. Band 2 -- Blue (490 nm)
3. Band 3 -- Green (560 nm)
4. Band 4 -- Red (665 nm)
5. Band 5 -- Red-edge 1 (705 nm)
6. Band 6 -- Red-edge 2 (740 nm)
7. Band 7 -- Red-edge 3 (783 nm)
8. 
    - on rasters with an output resolution < 20m:
        Band 8 -- NIR (842 nm)
    - on rasters with an output resolution >= 20m:
        Band 8A -- narrow NIR (865 nm)
9. Band 9 -- Water vapour (940 nm)
- on <span style='font-family:monospace;color:#FF6611;'>TOA</span> images:\
    &nbsp;10. Band 10 -- Cirrus (1375 nm)\
    &nbsp;11. Band 11 -- SWIR1 (1610 nm)\
    &nbsp;12. Band 12 -- SWIR2 (2190 nm)
- on <span style='font-family:monospace;color:#FF6611;'>BOA</span> images:\
    &nbsp;10. Band 11 -- SWIR1 (1610 nm)\
    &nbsp;11. Band 12 -- SWIR2 (2190 nm)

Bands are named if an output ENVI format is chosen. 

For details about Sentinel-2 bands, refer to
<a href="https://sentinel.esa.int/web/sentinel/user-guides/sentinel-2-msi/resolutions/radiometric" target="_blank">this page</a>.

All bands are reshaped with the same resolution.
In case the user chose a native resolution (10, 20 or 60 m), 
bands with a finest resolution are downscaled using an averaged method,
while pixels of bands with a coarse resolution are replicated without any interpolation method;
conversely, in case the user chose a custom resolution, the chosen resampling method is used.

Bands 8 and 8A are alternatively included, basing on the required output resolution.
That is due to the fact that they cover an overlapping spectral window; 
so, band 8A (finer radiometric resolution, coarse spatial one) is provided when the
output spatial resolution is adequate to include it (>= 20m), otherwise band 8 is used.
The possibility to include both NIR bands could be included in a future release.

Reflectances values are provided in integer output type (multiplicated by 10000),
as well as original values included in SAFE archives.


### Accessory layers

#### Scene Classification Map
<span style='font-family:monospace;color:#FF6611;'>SCL</span>
(Scene Classification Maps) are single band rasters provided within Level-2A
SAFE archives. Each 20-metres pixel is classified in one of the following classes:

0. <font style="family:monospace;background-color:#000000;color:white;">&nbsp; No data &nbsp;</font>&nbsp; 
1. <font style="family:monospace;background-color:#FF0000;color:white;">&nbsp; Saturated or defective &nbsp;</font>&nbsp; 
2. <font style="family:monospace;background-color:#424142;color:white;">&nbsp; Dark area pixels &nbsp;</font>&nbsp; 
3. <font style="family:monospace;background-color:#633400;color:white;">&nbsp; Cloud shadows &nbsp;</font>&nbsp; 
4. <font style="family:monospace;background-color:#29f329;color:black;">&nbsp; Vegetation &nbsp;</font>&nbsp; 
5. <font style="family:monospace;background-color:#ffff00;color:black;">&nbsp; Bare soils &nbsp;</font>&nbsp; 
6. <font style="family:monospace;background-color:#0000ff;color:white;">&nbsp; Water &nbsp;</font>&nbsp; 
7. <font style="family:monospace;background-color:#7b7d7b;color:white;">&nbsp; Unclassified &nbsp;</font>&nbsp; 
8. <font style="family:monospace;background-color:#bdbebd;color:black;">&nbsp; Cloud (medium probability) &nbsp;</font>&nbsp; 
9. <font style="family:monospace;background-color:#ffffff;color:black;">&nbsp; Cloud (high probability) &nbsp;</font>&nbsp; 
10. <font style="family:monospace;background-color:#63cbff;color:black;">&nbsp; Thin cirrus &nbsp;</font>&nbsp; 
11. <font style="family:monospace;background-color:#ff9aff;color:black;">&nbsp; Snow &nbsp;</font>&nbsp; 

For further details about this product, see 
<a href="https://earth.esa.int/web/sentinel/technical-guides/sentinel-2-msi/level-2a/algorithm" target="_blank">this page</a>.

<span style='font-family:monospace;color:#FF6611;'>SCL</span> are used as 
intermediate layers for cloud masking, but they can be also required as output formats.
If cloud masking is required by the user, <span style='font-family:monospace;color:#FF6611;'>SCL</span>
maps are never masked.

#### Cloud and snow probability
<span style='font-family:monospace;color:#FF6611;'>CLD</span> (cloud probability) and
<span style='font-family:monospace;color:#FF6611;'>SNW</span> (snow probability)
are single band rasters provided within Level-2A
SAFE archives, representing the percentage probability (0-100 Byte values) of each
20 metres pixel to be cloud- or snow-covered.
If cloud masking is required by the user, <span style='font-family:monospace;color:#FF6611;'>CLD</span>
and <span style='font-family:monospace;color:#FF6611;'>SNW</span> maps are never masked.
Currently these layers cannot be used for cloud masking (only 
<span style='font-family:monospace;color:#FF6611;'>SCL</span> can).

#### Water vapour column
<span style='font-family:monospace;color:#FF6611;'>WVP</span> is a single
band raster provided within Level-2A SAFE archives, representing the water
vapour column depth. 
Data type is Int16 (values must be multiplicated
by 1000 to obtain floating values in centimetres).
Typical ranges of water vapour columns are (sea-level-to space):
tropical conditions: <span style='font-family:monospace;color:#FF6611;'>WVP</span> = 3-5 cm;
mid-altitude summer: <span style='font-family:monospace;color:#FF6611;'>WVP</span> = 2-3 cm;
dry summer, spring, fall: <span style='font-family:monospace;color:#FF6611;'>WVP</span> = 1-1.5 cm;
dry desert or winter: <span style='font-family:monospace;color:#FF6611;'>WVP</span> = 0.3-0.8 cm.

For further details about this product, see the
<a href="http://step.esa.int/thirdparties/sen2cor/2.5.5/docs/S2-PDGS-MPC-L2A-PDD-V2.5.5.pdf" target="_blank">
Sentinel-2 Level 2A Product Definition</a> document.

### Aerosol Optical Thickness
<span style='font-family:monospace;color:#FF6611;'>AOT</span> is a single
band raster provided within Level-2A SAFE archives, representing the aerosol
optical thickness. 
It is defined as the integrated extinction coefficient over a vertical column 
of atmosphere of unit cross section. 
Extinction coefficient is the fractional depletion of radiance per unit path
length (also called attenuation for radar frequencies). 
Data type is Int16 (values must be multiplicated by 1000 to obtain original values).
If cloud masking is required by the user,
<span style='font-family:monospace;color:#FF6611;'>AOT</span> is never masked.

For further details about this product, see the
<a href="http://step.esa.int/thirdparties/sen2cor/2.5.5/docs/S2-PDGS-MPC-L2A-PDD-V2.5.5.pdf" target="_blank">
Sentinel-2 Level 2A Product Definition</a> document.

### Spectral indices

Spectral indices are single band rasters computed from 
<span style='font-family:monospace;color:#FF6611;'>BOA</span> (by default)
or <span style='font-family:monospace;color:#FF6611;'>TOA</span> images
using function `s2_calcindices()` (or the main function `sen2r()`).

The list of the indices which can be computed can be seen in the GUI (fourth sheet).
In the GUI, the index formula is _usually_ graphically provided.
In order to check the formula which is used for index computation, the function
`list_indices()' can be used.
For example, the following command will return the formula of index NDVI:
```{r, eval = FALSE}
list_indices("s2_formula", "^NDVI$")
```
```
## [1] "(band_8-band_4)/(band_8+band_4)"
```
See the function documentation for other examples.

The output type can be both floating (in this case, the actual index value is 
provided) or integer (default; in this case, values are multiplicated by a 
scaling factor, 10000 by default).
So, if the user did not change the arguments `outType` and `scaleFactor` of
function `s2_calcindices()`, or `index_datatype` of function `sen2r()`, 
raster values will be multiplicated by 10000 respect to the "expected" index values.

### RGB colour images

RGB are three-bands raster in 24-bit format, computed from 
<span style='font-family:monospace;color:#FF6611;'>BOA</span> 
or <span style='font-family:monospace;color:#FF6611;'>TOA</span> images
using function `s2_rgb()` (or the main function `sen2r()`).

Users can customise the bands used to produce images, as well as the 
reflectance ranges of each band and the source 
(<span style='font-family:monospace;color:#FF6611;'>BOA</span> 
or <span style='font-family:monospace;color:#FF6611;'>TOA</span>):
the easiest way to do this is to use the GUI (fifth sheet),
or to properly set the arguments of function `s2_rgb()`.

If cloud masking is required by the user, RGB are never masked
(this because they are thought for visualisation).

The names of RGB products contains information about reflectance source
and reproduced bands (see the next section).


## Naming convention

ESA Sentinel-2 naming convention is particularly long-winded; so, a different
convention was adopted, follows this schema:

<span style='font-family:monospace;font-weight:bold;'><span style='color:#FF3300;'>S2mll</span>\_<span style='color:#FF3300;'>yyyymmdd</span>\_<span style='color:#FF3300;'>rrr</span>\_<span style='color:#FF3300;'>EXTNAME</span>\_<span style='color:#FF3300;'>PROD</span>\_<span style='color:#FF3300;'>rr</span>\.<span style='color:#FF3300;'>fff</span></span>

(e.g. <span style='font-family:monospace;'><span style='color:#FF6611;'>S2A2A</span>\_<span style='color:#FF6611;'>20190723</span>\_<span style='color:#FF6611;'>022</span>\_<span style='color:#FF6611;'>Barbellino</span>\_<span style='color:#FF6611;'>BOA</span>\_<span style='color:#FF6611;'>10</span>\.<span style='color:#FF6611;'>tif</span></span>)

 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>S2mll</span>
     (length: 5) shows the mission ID 
     (<span style='font-family:monospace;color:#FF6611;'>S2A</span> or 
     <span style='font-family:monospace;color:#FF6611;'>S2B</span>) 
     and the product level 
     (<span style='font-family:monospace;color:#FF6611;'>1C</span> or 
     <span style='font-family:monospace;color:#FF6611;'>2A</span>);
 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>yyyymmdd</span>
     (length: 8) is the sensing date (e.g. 
     <span style='font-family:monospace;color:#FF6611;'>20190723</span> for 2019-07-23); 
     the hour is skipped, since a single sensor can not pass 
     two times in a day on the same tile);
 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>rrr</span>
     (length: 3) is the relative orbit number (e.g. 
     <span style='font-family:monospace;color:#FF6611;'>022</span>);
 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>EXTNAME</span>
     (length: variable, see [details](#extent-name))
     is the output extent name (e.g. 
     <span style='font-family:monospace;color:#FF6611;'>Barbellino</span>);
     it could also be the the tile number (length: 5 -- e.g. 
     <span style='font-family:monospace;color:#FF6611;'>32TQQ</span>)
     for outputs of function `s2_translate()`,
     and is kept empty for outputs of function `s2_merge()`;
 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>PROD</span>
     (length: variable) is the output product name, being one of these:
     - an output product: 
         <span style='font-family:monospace;color:#FF6611;'>TOA</span>
         (13-bands Top-Of-Atmosphere Reflectance),
         <span style='font-family:monospace;color:#FF6611;'>BOA</span>
         (13-bands Bottom-Of-Atmosphere Reflectance) or 
         <span style='font-family:monospace;color:#FF6611;'>SCL</span>
         (Scene Classification Map);
     - a spectral index name (the list of supported index names can be obtained
         with the function `list_indices("name")`);
     - the name of a RGB image (length: 7, see [details](#rgb-names)).
 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>rr</span>
     (length: 2) is the original minimum spatial resolution in metres
     (<span style='font-family:monospace;color:#FF6611;'>10</span>, 
     <span style='font-family:monospace;color:#FF6611;'>20</span> or 
     <span style='font-family:monospace;color:#FF6611;'>60</span>);
 * <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>fff</span>
     (length: variable, generally 3) is the file extension
     (e.g. <span style='font-family:monospace;color:#FF6611;'>tif</span>).


### Extent name
The extent name is defined with the argument `extent_name` of function `sen2r()`.

The user can choose any non-empty alphanumeric string as extent name, as long 
as it does not contain spaces, points nor underscores, and as long as it is not 
a five-length string with the same structure of a tile ID
(two numeric and three uppercase character values), 
because this structure is reserved for intermediate layers.


### RGB names
The names of RGB images are 7-length strings following the structure
<span style='font-family:monospace;font-weight:bold;color:#FF3300;'>RGBrgbX</span>
(e.g. <span style='font-family:monospace;color:#FF6611;'>RGBb84B</span>),
where:

- <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>r</span>, 
    <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>g</span> and
    <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>b</span>
    are the number of the bands to be used respectively for red, green and blue, 
    in hexadecimal format (in the example above, 
    <span style='font-family:monospace;color:#FF6611;'>b</span>, 
    <span style='font-family:monospace;color:#FF6611;'>8</span> and 
    <span style='font-family:monospace;color:#FF6611;'>4</span>
    correspond to bands 11, 8 and 4);
- <span style='color:#FF3300;font-family:monospace;font-weight:bold;'>X</span>
    is <span style='font-family:monospace;color:#FF6611;'>B</span> if index 
    source is <span style='font-family:monospace;color:#FF6611;'>BOA</span>, 
    or <span style='font-family:monospace;color:#FF6611;'>T</span> if source is 
    <span style='font-family:monospace;color:#FF6611;'>TOA</span>.


## Folder structure

Processing functions allows setting an output directory using the arguments 
`path_out`, `path_rgb` and `path_indices` (`sen2r()`) or `outdir` 
(`s2_translate()`, `s2_merge()`, `s2_mask()`, `s2_rgb()` and `s2_calcindices()`).
These folders are automatically created if their parent directories exist.

By default, functions create a subfolder for each product / index / RGB type,
in which files are stored.
Each product subfolder includes a sub-subfolder named `thumbnails`,
which contains small JPEG or PNG images which can be used to rapidly monitor
what was done (see `s2_thumbnails()` for further details).

For example, the following command would produce the outputs listed below.
```{r, eval=FALSE}
json_path <- build_example_param_file()
out_dir_1 <- tempfile(pattern = "sen2r_out_1_")

library(sen2r)
sen2r(
  json_path, 
  timewindow = c("2019-07-13","2019-07-23"),
  path_out = out_dir_1
)
```
```
[2020-02-06 09:42:40] #### Starting sen2r execution. ####
[2020-02-06 09:42:40] Searching for available SAFE products on SciHub...
[2020-02-06 09:42:46] Computing output names...
[2020-02-06 09:42:48] Processing group 1 of 5...
```
_Most of output message were skipped;_
_see [this vignette](sen2r_cmd.html) for further details._
```
╔══════════════════════════════════════════════════════════════════════════════
║ sen2r Processing Report
╟──────────────────────────────────────────────────────────────────────────────
║ Dates to be processed based on processing parameters: 5
║ Processing completed for: all expected dates.
╚══════════════════════════════════════════════════════════════════════════════
[2020-02-06 09:44:45] #### sen2r session terminated. ####
The processing chain can be re-launched with the command:
  sen2r("/home/lranghetti/.sen2r/proc_par/s2proc_20200206_094240.json")
```
```{r, eval=FALSE}
system(paste("tree", out_dir_1)) # working on Linux with binary "tree" installed
```
```
/tmp/RtmpUlAdHw/sen2r_out_1_a55119f4ed09
├── BOA
│   ├── S2A2A_20190713_022_sen2r_BOA_10.tif
│   ├── S2A2A_20190716_065_sen2r_BOA_10.tif
│   ├── S2A2A_20190723_022_sen2r_BOA_10.tif
│   ├── S2B2A_20190718_022_sen2r_BOA_10.tif
│   ├── S2B2A_20190721_065_sen2r_BOA_10.tif
│   └── thumbnails
│       ├── S2A2A_20190713_022_sen2r_BOA_10.jpg
│       ├── S2A2A_20190713_022_sen2r_BOA_10.jpg.aux.xml
│       ├── S2A2A_20190716_065_sen2r_BOA_10.jpg
│       ├── S2A2A_20190716_065_sen2r_BOA_10.jpg.aux.xml
│       ├── S2A2A_20190723_022_sen2r_BOA_10.jpg
│       ├── S2A2A_20190723_022_sen2r_BOA_10.jpg.aux.xml
│       ├── S2B2A_20190718_022_sen2r_BOA_10.jpg
│       ├── S2B2A_20190718_022_sen2r_BOA_10.jpg.aux.xml
│       ├── S2B2A_20190721_065_sen2r_BOA_10.jpg
│       └── S2B2A_20190721_065_sen2r_BOA_10.jpg.aux.xml
├── MSAVI2
│   ├── S2A2A_20190713_022_sen2r_MSAVI2_10.tif
│   ├── S2A2A_20190716_065_sen2r_MSAVI2_10.tif
│   ├── S2A2A_20190723_022_sen2r_MSAVI2_10.tif
│   ├── S2B2A_20190718_022_sen2r_MSAVI2_10.tif
│   ├── S2B2A_20190721_065_sen2r_MSAVI2_10.tif
│   └── thumbnails
│       ├── S2A2A_20190713_022_sen2r_MSAVI2_10.jpg
│       ├── S2A2A_20190713_022_sen2r_MSAVI2_10.jpg.aux.xml
│       ├── S2A2A_20190716_065_sen2r_MSAVI2_10.jpg
│       ├── S2A2A_20190716_065_sen2r_MSAVI2_10.jpg.aux.xml
│       ├── S2A2A_20190723_022_sen2r_MSAVI2_10.jpg
│       ├── S2A2A_20190723_022_sen2r_MSAVI2_10.jpg.aux.xml
│       ├── S2B2A_20190718_022_sen2r_MSAVI2_10.jpg
│       ├── S2B2A_20190718_022_sen2r_MSAVI2_10.jpg.aux.xml
│       ├── S2B2A_20190721_065_sen2r_MSAVI2_10.jpg
│       └── S2B2A_20190721_065_sen2r_MSAVI2_10.jpg.aux.xml
├── NDVI
│   ├── S2A2A_20190713_022_sen2r_NDVI_10.tif
│   ├── S2A2A_20190716_065_sen2r_NDVI_10.tif
│   ├── S2A2A_20190723_022_sen2r_NDVI_10.tif
│   ├── S2B2A_20190718_022_sen2r_NDVI_10.tif
│   ├── S2B2A_20190721_065_sen2r_NDVI_10.tif
│   └── thumbnails
│       ├── S2A2A_20190713_022_sen2r_NDVI_10.jpg
│       ├── S2A2A_20190713_022_sen2r_NDVI_10.jpg.aux.xml
│       ├── S2A2A_20190716_065_sen2r_NDVI_10.jpg
│       ├── S2A2A_20190716_065_sen2r_NDVI_10.jpg.aux.xml
│       ├── S2A2A_20190723_022_sen2r_NDVI_10.jpg
│       ├── S2A2A_20190723_022_sen2r_NDVI_10.jpg.aux.xml
│       ├── S2B2A_20190718_022_sen2r_NDVI_10.jpg
│       ├── S2B2A_20190718_022_sen2r_NDVI_10.jpg.aux.xml
│       ├── S2B2A_20190721_065_sen2r_NDVI_10.jpg
│       └── S2B2A_20190721_065_sen2r_NDVI_10.jpg.aux.xml
├── RGB432B
│   ├── S2A2A_20190713_022_sen2r_RGB432B_10.tif
│   ├── S2A2A_20190716_065_sen2r_RGB432B_10.tif
│   ├── S2A2A_20190723_022_sen2r_RGB432B_10.tif
│   ├── S2B2A_20190718_022_sen2r_RGB432B_10.tif
│   ├── S2B2A_20190721_065_sen2r_RGB432B_10.tif
│   └── thumbnails
│       ├── S2A2A_20190713_022_sen2r_RGB432B_10.jpg
│       ├── S2A2A_20190713_022_sen2r_RGB432B_10.jpg.aux.xml
│       ├── S2A2A_20190716_065_sen2r_RGB432B_10.jpg
│       ├── S2A2A_20190716_065_sen2r_RGB432B_10.jpg.aux.xml
│       ├── S2A2A_20190723_022_sen2r_RGB432B_10.jpg
│       ├── S2A2A_20190723_022_sen2r_RGB432B_10.jpg.aux.xml
│       ├── S2B2A_20190718_022_sen2r_RGB432B_10.jpg
│       ├── S2B2A_20190718_022_sen2r_RGB432B_10.jpg.aux.xml
│       ├── S2B2A_20190721_065_sen2r_RGB432B_10.jpg
│       └── S2B2A_20190721_065_sen2r_RGB432B_10.jpg.aux.xml
├── RGB843B
│   ├── S2A2A_20190713_022_sen2r_RGB843B_10.tif
│   ├── S2A2A_20190716_065_sen2r_RGB843B_10.tif
│   ├── S2A2A_20190723_022_sen2r_RGB843B_10.tif
│   ├── S2B2A_20190718_022_sen2r_RGB843B_10.tif
│   ├── S2B2A_20190721_065_sen2r_RGB843B_10.tif
│   └── thumbnails
│       ├── S2A2A_20190713_022_sen2r_RGB843B_10.jpg
│       ├── S2A2A_20190713_022_sen2r_RGB843B_10.jpg.aux.xml
│       ├── S2A2A_20190716_065_sen2r_RGB843B_10.jpg
│       ├── S2A2A_20190716_065_sen2r_RGB843B_10.jpg.aux.xml
│       ├── S2A2A_20190723_022_sen2r_RGB843B_10.jpg
│       ├── S2A2A_20190723_022_sen2r_RGB843B_10.jpg.aux.xml
│       ├── S2B2A_20190718_022_sen2r_RGB843B_10.jpg
│       ├── S2B2A_20190718_022_sen2r_RGB843B_10.jpg.aux.xml
│       ├── S2B2A_20190721_065_sen2r_RGB843B_10.jpg
│       └── S2B2A_20190721_065_sen2r_RGB843B_10.jpg.aux.xml
└── SCL
    ├── S2A2A_20190713_022_sen2r_SCL_10.tif
    ├── S2A2A_20190716_065_sen2r_SCL_10.tif
    ├── S2A2A_20190723_022_sen2r_SCL_10.tif
    ├── S2B2A_20190718_022_sen2r_SCL_10.tif
    ├── S2B2A_20190721_065_sen2r_SCL_10.tif
    └── thumbnails
        ├── S2A2A_20190713_022_sen2r_SCL_10.png
        ├── S2A2A_20190713_022_sen2r_SCL_10.png.aux.xml
        ├── S2A2A_20190716_065_sen2r_SCL_10.png
        ├── S2A2A_20190716_065_sen2r_SCL_10.png.aux.xml
        ├── S2A2A_20190723_022_sen2r_SCL_10.png
        ├── S2A2A_20190723_022_sen2r_SCL_10.png.aux.xml
        ├── S2B2A_20190718_022_sen2r_SCL_10.png
        ├── S2B2A_20190718_022_sen2r_SCL_10.png.aux.xml
        ├── S2B2A_20190721_065_sen2r_SCL_10.png
        └── S2B2A_20190721_065_sen2r_SCL_10.png.aux.xml

12 directories, 90 files
```
In each of the 6 subfolders `BOA`, `MSAVI2`, `NDVI`, `RGB432B`, `RGB843B` and `SCL`
5 products (one for each date) were created.
Sub-subfolders `thumbnails` contains thumbnail images.

Users can skip the creation of products' subfolders setting the argument
`sen2r(..., path_subdirs = FALSE)` (default: `TRUE`), or doing the same with
the argument `subdir` of other processing functions.
The creation of thumbnails can be skipped using `sen2r(..., thumbnails = FALSE)`
(default: `TRUE`).
Both the options can be also set [using the `sen2r()` GUI](sen2r_gui.html).

For example, the following command would produce the outputs listed below.
```{r, eval=FALSE}
out_dir_2 <- tempfile(pattern = "sen2r_out_2_")

sen2r(
  json_path, 
  timewindow = c("2019-07-13","2019-07-23"),
  path_out = out_dir_2,
  path_subdirs = FALSE,
  thumbnails = FALSE
)
```
```
[2020-02-06 09:52:30] #### Starting sen2r execution. ####
[2020-02-06 09:52:30] Searching for available SAFE products on SciHub...
[2020-02-06 09:52:35] Computing output names...
[2020-02-06 09:52:36] Processing group 1 of 5...

# most of output message were skipped

╔══════════════════════════════════════════════════════════════════════════════
║ sen2r Processing Report
╟──────────────────────────────────────────────────────────────────────────────
║ Dates to be processed based on processing parameters: 5
║ Processing completed for: all expected dates.
╚══════════════════════════════════════════════════════════════════════════════
[2020-02-06 09:54:16] #### sen2r session terminated. ####
The processing chain can be re-launched with the command:
  sen2r("/home/lranghetti/.sen2r/proc_par/s2proc_20200206_095230.json")
```
```{r, eval=FALSE}
system(paste("tree", out_dir_2))
```
```
/tmp/RtmpUlAdHw/sen2r_out_2_a5513ad348b0
├── S2A2A_20190713_022_sen2r_BOA_10.tif
├── S2A2A_20190713_022_sen2r_MSAVI2_10.tif
├── S2A2A_20190713_022_sen2r_NDVI_10.tif
├── S2A2A_20190713_022_sen2r_RGB432B_10.tif
├── S2A2A_20190713_022_sen2r_RGB843B_10.tif
├── S2A2A_20190713_022_sen2r_SCL_10.tif
├── S2A2A_20190716_065_sen2r_BOA_10.tif
├── S2A2A_20190716_065_sen2r_MSAVI2_10.tif
├── S2A2A_20190716_065_sen2r_NDVI_10.tif
├── S2A2A_20190716_065_sen2r_RGB432B_10.tif
├── S2A2A_20190716_065_sen2r_RGB843B_10.tif
├── S2A2A_20190716_065_sen2r_SCL_10.tif
├── S2A2A_20190723_022_sen2r_BOA_10.tif
├── S2A2A_20190723_022_sen2r_MSAVI2_10.tif
├── S2A2A_20190723_022_sen2r_NDVI_10.tif
├── S2A2A_20190723_022_sen2r_RGB432B_10.tif
├── S2A2A_20190723_022_sen2r_RGB843B_10.tif
├── S2A2A_20190723_022_sen2r_SCL_10.tif
├── S2B2A_20190718_022_sen2r_BOA_10.tif
├── S2B2A_20190718_022_sen2r_MSAVI2_10.tif
├── S2B2A_20190718_022_sen2r_NDVI_10.tif
├── S2B2A_20190718_022_sen2r_RGB432B_10.tif
├── S2B2A_20190718_022_sen2r_RGB843B_10.tif
├── S2B2A_20190718_022_sen2r_SCL_10.tif
├── S2B2A_20190721_065_sen2r_BOA_10.tif
├── S2B2A_20190721_065_sen2r_MSAVI2_10.tif
├── S2B2A_20190721_065_sen2r_NDVI_10.tif
├── S2B2A_20190721_065_sen2r_RGB432B_10.tif
├── S2B2A_20190721_065_sen2r_RGB843B_10.tif
└── S2B2A_20190721_065_sen2r_SCL_10.tif

0 directories, 30 files
```
