Learn R Programming

sits (version 0.10.0)

sits_cube.gdalcubes_cube: Create a composed data cube for a Sentinel-2 L2A AWS cube

Description

Creates composed cubes using the gdalcubes package. Cubes can be composed of the following functions: "min", "max", "mean", "median" or "first". To create the composition it is necessary to provide an image period, in which it is used to apply the composition function. For now, only Sentinel-2 L2A AWS cube can be composed.

Usage

# S3 method for gdalcubes_cube
sits_cube(
  type = "GDALCUBES",
  ...,
  cube,
  path_images,
  path_db = NULL,
  period = NULL,
  agg_method = NULL,
  resampling = "bilinear",
  cloud_mask = TRUE
)

Arguments

type

Type of cube.

...

Other parameters to be passed for the function write_tif of gdalcubes package.

cube

A Sentinel-2 L2A AWS data cube

path_images

A character with the path where the aggregated images will be write.

path_db

A character with the path and name where the database will be create. E.g. "my/path/gdalcubes.db"

period

A character with the period of time in which it is desired to apply in the cube, must be provided based on ISO8601, where 1 number and a unit are provided, for example "P16D" for 16 days. For unit, use "D", "M" and "Y" for days, month and year, respectively.

agg_method

A character with the method that will be applied in the aggregation, the following are available: "min", "max", "mean", "median" or "first".

resampling

A character with the method that will be applied in the resampling in mosaic operation. The following are available: "near", "bilinear", "bicubic" or others supported by gdalwarp (see https://gdal.org/programs/gdalwarp.html).

cloud_mask

A logical corresponds to the use of the cloud band for aggregation.

Value

A data cube.

References

APPEL, Marius; PEBESMA, Edzer. On-demand processing of data cubes from satellite image collections with the gdalcubes library. Data, v. 4, n. 3, p. 92, 2019. DOI: 10.3390/data4030092

Examples

Run this code
# NOT RUN {
# this example requires access to an external service, so should not be run
# by CRAN

# s3://sentinel-cogs/sentinel-s2-l2a-cogs/2017/S2A_35MNR_20171025_0_L2A/

# Provide your AWS credentials here
# Sys.setenv(
# "AWS_ACCESS_KEY_ID"     = <your_access_key>,
# "AWS_SECRET_ACCESS_KEY" = <your_secret_access_key>,
# "AWS_DEFAULT_REGION"    = <your AWS region>,
# "AWS_ENDPOINT" = "sentinel-s2-l2a.s3.amazonaws.com",
# "AWS_REQUEST_PAYER"     = "requester"
# )

s2_cube <- sits_cube(
    type = "S2_L2A_AWS",
    name = "T20LKP_2018_2019",
    satellite = "SENTINEL-2",
    sensor = "MSI",
    tiles = "20LKP",
    s2_aws_resolution = "20m",
    start_date = as.Date("2018-07-18"),
    end_date = as.Date("2018-07-23")
)

gc_cube <- sits_cube(type        = "GDALCUBES",
                     cube        = s2_cube,
                     path_db     = "/my/path/cube.db",
                     path_images = "/my/path/images/",
                     period      = "P1M",
                     agg_method  = "median",
                     resampling  = "bilinear")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab