From 3f2ca6c06526c25ab111a53fb4447cd4cca5f3a3 Mon Sep 17 00:00:00 2001 From: gilbertocamara Date: Sat, 24 Aug 2024 10:33:27 -0300 Subject: [PATCH] closes #1202 --- R/api_gdalcubes.R | 11 +++++++---- R/sits_regularize.R | 11 ++++++++++- man/sits_regularize.Rd | 3 ++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/R/api_gdalcubes.R b/R/api_gdalcubes.R index 21e24ec25..afd24ae2b 100644 --- a/R/api_gdalcubes.R +++ b/R/api_gdalcubes.R @@ -459,6 +459,7 @@ #' Use "D", "M" and "Y" for days, month and year. #' @param res Spatial resolution of the regularized images. #' @param roi A named \code{numeric} vector with a region of interest. +#' @param tiles Tiles to be produced #' @param multicores Number of cores used for regularization. #' @param progress Show progress bar? #' @param ... Additional parameters for httr package. @@ -468,6 +469,7 @@ period, res, roi, + tiles, output_dir, multicores = 1, progress = progress) { @@ -481,15 +483,16 @@ if (!dir.exists(temp_output_dir)) { dir.create(temp_output_dir, recursive = TRUE) } + # timeline of intersection + timeline <- .gc_get_valid_timeline(cube, period = period) # filter only intersecting tiles if (.has(roi)) { cube <- .cube_filter_spatial(cube, roi = roi) } - - # timeline of intersection - timeline <- .gc_get_valid_timeline(cube, period = period) - + if (.has(tiles)) { + cube <- .cube_filter_tiles(cube, tiles = tiles) + } # least_cc_first requires images ordered based on cloud cover cube <- .gc_arrange_images( cube = cube, diff --git a/R/sits_regularize.R b/R/sits_regularize.R index 6ab1aead7..492987c63 100644 --- a/R/sits_regularize.R +++ b/R/sits_regularize.R @@ -25,7 +25,7 @@ #' e.g., "P16D" for 16 days. #' @param res Spatial resolution of regularized images (in meters). #' @param roi A named \code{numeric} vector with a region of interest. -#' @param tiles MGRS tiles to be produced (only for Sentinel-1 cubes) +#' @param tiles Tiles to be produced. #' @param multicores Number of cores used for regularization; #' used for parallel processing of input (integer) #' @param output_dir Valid directory for storing regularized images. @@ -114,15 +114,23 @@ sits_regularize.raster_cube <- function(cube, ..., res, output_dir, roi = NULL, + tiles = NULL, multicores = 2L, progress = TRUE) { # Preconditions .check_raster_cube_files(cube) + # check period .check_period(period) + # check resolution .check_num_parameter(res, exclusive_min = 0) + # check output_dir output_dir <- .file_path_expand(output_dir) .check_output_dir(output_dir) + # check for ROI and tiles + .check_roi_tiles(roi, tiles) + # check multicores .check_num_parameter(multicores, min = 1, max = 2048) + # check progress .check_progress(progress) # Does cube contain cloud band? if (!all(.cube_contains_cloud(cube)) && .check_warnings()) { @@ -156,6 +164,7 @@ sits_regularize.raster_cube <- function(cube, ..., period = period, res = res, roi = roi, + tiles = tiles, output_dir = output_dir, multicores = multicores, progress = progress diff --git a/man/sits_regularize.Rd b/man/sits_regularize.Rd index 3a4190483..abe0441f8 100644 --- a/man/sits_regularize.Rd +++ b/man/sits_regularize.Rd @@ -28,6 +28,7 @@ sits_regularize( res, output_dir, roi = NULL, + tiles = NULL, multicores = 2L, progress = TRUE ) @@ -76,7 +77,7 @@ data cubes, with number and unit, where \item{roi}{A named \code{numeric} vector with a region of interest.} -\item{tiles}{MGRS tiles to be produced (only for Sentinel-1 cubes)} +\item{tiles}{Tiles to be produced.} \item{multicores}{Number of cores used for regularization; used for parallel processing of input (integer)}