Skip to content

Commit

Permalink
closes #1202
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertocamara committed Aug 24, 2024
1 parent 80263dd commit 3f2ca6c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 7 additions & 4 deletions R/api_gdalcubes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -468,6 +469,7 @@
period,
res,
roi,
tiles,
output_dir,
multicores = 1,
progress = progress) {
Expand All @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion R/sits_regularize.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion man/sits_regularize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f2ca6c

Please sign in to comment.