safe_shortname: Rename products using a shorten convention

View source: R/safe_shortname.R

safe_shortnameR Documentation

Rename products using a shorten convention

Description

This function renames a Sentinel-2 product in order to obtain shorten names. See the details for the structure of the adopted schema (named "sen2r naming convention"). The function applies only to compact product names (not to single granule names), since it is thought to be applied to entire products. Old long names are no more supported.

Usage

safe_shortname(
  prod_name,
  prod_type = NULL,
  ext = NULL,
  res = "10m",
  tiles = NULL,
  force_tiles = NULL,
  full.name = TRUE,
  allow_duplicated = FALSE,
  set.seed = NULL,
  multiple_names = NULL,
  abort = FALSE
)

Arguments

prod_name

Input Sentinel-2 product name (it is not required that the file exists).

prod_type

(optional) Output product (default: TOA for L1C, BOA for L2A); see the details for the list of accepted products.

ext

(optional) Extension of the output filename (default: none).

res

(optional) Spatial resolution (one between '10m', '20m' or '60m'); default is '10m'. Notice that, choosing '10m' or '20m', bands with lower resolution will be rescaled to res. Band 08 is used with res = '10m', band 08A with res = '20m' and res = '60m'.

tiles

Deprecated (no more used).

force_tiles

Deprecated (no more used).

full.name

Logical value: if TRUE (default), all the input path is maintained (if existing); if FALSE, only basename is returned.

allow_duplicated

Logical value: if TRUE, duplicated values are maintained; if FALSE (default), in case of duplicated value a suffix is added to the tile ID (see add_tile_suffix()).

set.seed

Deprecated (no more used).

multiple_names

Deprecated (no more used).

abort

Logical parameter: if TRUE, the function aborts in case prod_type is not recognised; if FALSE (default), a warning is shown.

Details

ESA Sentinel-2 naming convention is particularly long-winded. So, the convention here adopted, named "sen2r naming convention", follows this schema:

S2mll_yyyymmdd_rrr_ttttt_ppp_rr.fff

where:

  • S2mll (length: 5) shows the mission ID (S2A or S2B) and the product level (⁠1C⁠ or ⁠2A⁠);

  • yyyymmdd (length: 8) is the sensing date (e.g. 20170603 for 2017-06-03) ; the hour is skipped, since a single sensor can not pass two times in a day on the same tile);

  • rrr (length: 3) is the relative orbit number (e.g. 022);

  • ttttt (length: 5) is the tile number (e.g. ⁠32TQQ⁠);

  • ppp (length: 3) is the output product, being one of these: for level 1C:

    • TOA: 13-bands Top-Of-Atmosphere Reflectance; for level 2A:

    • BOA: 13-bands Bottom-Of-Atmosphere Reflectance;

    • TCI: True Colour Image (3-band RGB 8-bit image);

    • AOT: Aerosol Optical Thickness;

    • WVP: Water Vapour;

    • SCL: Scene Classification Map;

    • CLD: Quality Indicators for cloud probabilities;

    • SNW: Quality Indicators for snow probabilities;

    • VIS: TODO Visibility (used for AOT); for both levels:

    • SZA: Sun Zenith Angles;

    • SAA: Sun Azimuth Angles;

    • OZA: averaged Viewing Incidence Zenith Angles;

    • OAA: averaged Viewing Incidence Azimuth Angles.

  • rr (length: 2) is the original minimum spatial resolution in metres (10, 20 or 60);

  • fff (length: variable, generally 3) is the file extension.

Value

Output product name

Note

License: GPL 3.0

Author(s)

Luigi Ranghetti, phD (2019)

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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473")}, URL: https://sen2r.ranghetti.info/.

Examples

safe_shortname("S2A_MSIL1C_20170603T101031_N0205_R022_T32TQQ_20170603T101026.SAFE", ext="tif")

ranghetti/fidolasen documentation built on March 27, 2024, 9:37 p.m.