s2_angles: Extract sun angles from SAFE archives

View source: R/s2_angles.R

s2_anglesR Documentation

Extract sun angles from SAFE archives

Description

The function extracts sun angle rasters from a SAFE archive, reshaping the original information (5 km resolution) to the desired Sentinel-2 output resolution. It was not exported because it is intended to be called by s2_translate.

Usage

s2_angles(
  infiles,
  outdir = ".",
  subdirs = NA,
  tmpdir = NA,
  rmtmp = TRUE,
  prod_type = c("SZA", "OZA", "SAA", "OAA"),
  res = "10m",
  method = "bilinear",
  format = "VRT",
  compress = "DEFLATE",
  bigtiff = FALSE,
  overwrite = FALSE
)

Arguments

infiles

Full paths of the input SAFE folders.

outdir

(optional) Full name of the output directory where the files should be created (default: current directory). outdir can bot be an existing or non-existing directory (in the second case, its parent directory must exists). If it is a relative path, it is expanded from the directory of infile.

subdirs

(optional) Logical: if TRUE, different output products are placed in separated outdir subdirectories; if FALSE, they are placed in outdir directory; if NA (default), subdirectories are created only if prod_type has length > 1.

tmpdir

(optional) Path where intermediate files will be created. Default is a temporary directory. If tmpdir is a non-empty folder, a random subdirectory will be used.

rmtmp

(optional) Logical: should temporary files be removed? (Default: TRUE).

prod_type

(optional) Vector of types (angles) to be produced as outputs. Default is all the possible types ("SZA" for Sun Angles Grid at Zenith, "SAA" for Sun Angles Grid at Azimuth, "OZA" for Viewing Incidence Angles at Zenith averaged Grid, "OAA" for Viewing Incidence Angles at Azimuth averaged Grid).

res

(optional) Spatial resolution (one between '10m', '20m' or '60m'); default is '10m'.

method

(optional) A method used to resample the output rasters (accepted values are valid values accepted by -r option of gdalwarp). Default is "bilinear" (linear interpolation).

format

(optional) Format of the output file (in a format recognised by GDAL). Default value is "VRT" (Virtual Raster).

compress

(optional) In the case a GeoTIFF format is chosen, the compression indicated with this parameter is used.

bigtiff

(optional) Logical: if TRUE, the creation of a BigTIFF is forced (default is FALSE). This option is used only in the case a GeoTIFF format was chosen.

overwrite

Logical value: should existing output files be overwritten? (default: FALSE)

Value

A vector with the names of the created output files (just created or already existing).

Note

License: GPL 3.0

Author(s)

Luigi Ranghetti, phD (2022)

Marina Ranghetti (2022)

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

## Not run: 

s2_l2a_example <- file.path(
  "/existing/path",
  "S2B_MSIL2A_20200801T100559_N0214_R022_T32TNR_20200801T135302.SAFE"
)

# Create all products
s2_angles(s2_l2a_example, outdir = tempdir())

# Create only Viewing Incidence Angles at Azimuth, at 60 m resolution,
# with cubic interpolation, in ENVI format
s2_angles(
  s2_l2a_example, 
  outdir = tempdir(), 
  prod_type = "OAA", 
  res = "60m",
  method = "cubic",
  format = "ENVI"
)

## End(Not run)

sen2r documentation built on Nov. 10, 2023, 9:08 a.m.