add_tile_suffix()
adds specific suffixes to tile IDs
in order to distinguish tiled filenames referring to different original
SAFE products.
remove_tile_suffix()
removes existing suffixes from tile IDs.
extract_tile_suffix()
extracts suffixes from input paths.
add_tile_suffix(paths, suffix)
remove_tile_suffix(paths)
extract_tile_suffix(paths)
Paths of the input tiled products
Character (1-length): if provided, the specified suffix is appended to the tile ID of each path; if not provided (default), a sequential suffix is appended only to the tile ID of the duplicated paths.
The input paths with/without the tile suffix.
In some sporadic cases, a tiled Sentinel-2 image is split in two
SAFE products (see e.g. products
S2A_MSIL1C_20200408T101021_N0209_R022_T32TNL_20200408T153254
and
S2A_MSIL1C_20200408T101021_N0209_R022_T32TNL_20200408T171107
).
This split, probably a consequence of the division of the whole orbit image,
creates ambiguity in the association among SAFE images and sen2r
products,
since the sen2r naming convention is not sufficient to manage them as separate
products.
So, in the definition of the filenames of intermediate tiled products
(output of s2_translate()
) it is necessary to add a suffix to be able to
manage them separately and then merge them in s2_merge()
.
A lowercase letter ("a" and "b", but potentially "a" to "z") is used.
Functions add_tile_suffix()
and remove_tile_suffix()
are used in the
sen2r()
main code as a workaround.
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/.
safe_names <- c(
"S2A_MSIL2A_20200408T101021_N0214_R022_T32TNK_20200408T175711.SAFE",
"S2A_MSIL2A_20200408T101021_N0214_R022_T32TNL_20200408T175711.SAFE",
"S2A_MSIL2A_20200408T101021_N0214_R022_T32TNL_20200408T161405.SAFE"
)
prod_names <- safe_shortname(safe_names, ext = ".tif", allow_duplicated = TRUE)
( prod_names_univoc <- sen2r:::add_tile_suffix(prod_names) )
#> [1] "S2A2A_20200408_022_32TNK_BOA_10.tif"
#> [2] "S2A2A_20200408_022_32TNLa_BOA_10.tif"
#> [3] "S2A2A_20200408_022_32TNLb_BOA_10.tif"
( prod_names_custom <- sen2r:::add_tile_suffix(prod_names, "a") )
#> [1] "S2A2A_20200408_022_32TNKa_BOA_10.tif"
#> [2] "S2A2A_20200408_022_32TNLa_BOA_10.tif"
#> [3] "S2A2A_20200408_022_32TNLb_BOA_10.tif"
sen2r:::remove_tile_suffix(prod_names_univoc)
#> [1] "S2A2A_20200408_022_32TNK_BOA_10.tif" "S2A2A_20200408_022_32TNL_BOA_10.tif"
#> [3] "S2A2A_20200408_022_32TNL_BOA_10.tif"