Learn R Programming

sen2r (version 1.6.0)

add_tile_suffix: Add/remove suffixes for split tiles

Description

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.

Usage

add_tile_suffix(paths, suffix)

remove_tile_suffix(paths)

extract_tile_suffix(paths)

Value

The input paths with/without the tile suffix.

Arguments

paths

Paths of the input tiled products

suffix

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.

Author

Luigi Ranghetti, phD (2020)

Details

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.

References

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. tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473"), URL: https://sen2r.ranghetti.info/.

Examples

Run this code
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) )
( prod_names_custom <- sen2r:::add_tile_suffix(prod_names, "a") )
sen2r:::remove_tile_suffix(prod_names_univoc)

Run the code above in your browser using DataLab