R: Creates a regularized data cube from an irregular one

sits_regularize {sits} | R Documentation

## Creates a regularized data cube from an irregular one

### Description

Creates cubes with regular time intervals using the gdalcubes package. Cubes are composed using "min", "max", "mean", "median" or "first" functions. Users need to provide an time interval which is used by the composition function.

### Usage

    sits_regularize(
      cube,
      name,
      dir_images,
      period = NULL,
      roi = NULL,
      agg_method = NULL,
      resampling = "bilinear",
      cloud_mask = TRUE
    )

### Arguments

`cube` | A cube whose spacing of observation times is not constant and will be regularized by the "gdalcubes" packges
`name` | Name of the output data cube
`dir_images` | Directory where the regularized images will be written by `gdalcubes`.
`period` | ISO8601 time period for regular data cubes produced by `gdalcubes`, with number and unit, e.g., "P16D" for 16 days. Use "D", "M" and "Y" for days, month and year..
`roi` | a region of interest (see above)
`agg_method` | Method that will be applied by `gdalcubes` for aggregation. Options: "min", "max", "mean", "median" and "first".
`resampling` | Method to be used by `gdalcubes` for resampling in mosaic operation. Options: "near", "bilinear", "bicubic" or others supported by gdalwarp (see https://gdal.org/programs/gdalwarp.html).
`cloud_mask` | Use cloud band for aggregation by `gdalcubes`?

### Note

The "roi" parameter defines a region of interest. It can be an sf_object, a shapefile, or a bounding box vector with named XY values ("xmin", "xmax", "ymin", "ymax") or named lat/long values ("lat_min", "lat_max", "long_min", "long_max")

### 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

    {
    ## Not run:

    # --- Access to the AWS STAC
    # Provide your AWS credentials as environment variables
    Sys.setenv(
        "AWS_ACCESS_KEY_ID" = <your_aws_access_key>,
        "AWS_SECRET_ACCESS_KEY" = <your_aws_secret_access_key>
    )

    # define an AWS data cube
      s2_cube <- sits_cube(source = "AWS",
                          name = "T20LKP_2018_2019",
                          collection = "sentinel-s2-l2a",
                          bands = c("B08", "SCL"),
                          tiles = c("20LKP"),
                          start_date = as.Date("2018-07-18"),
                          end_date = as.Date("2018-08-18"),
                          s2_resolution = 60
    )

    # create a directory to store the resulting images
    dir.create(paste0(tempdir(),"/images/"))

     # Build a data cube of equal intervals using the "gdalcubes" package
    gc_cube <- sits_regularize(cube   = s2_cube,
                         name          = "T20LKP_2018_2019_1M",
                         dir_images   = paste0(tempdir(),"/images/"),
                         period        = "P1M",
                         agg_method    = "median",
                         resampling    = "bilinear",
                         cloud_mask    = TRUE)

    ## End(Not run)
    }

[Package sits version 0.12.0 Index]