diff --git a/.gitignore b/.gitignore index c5fd67e53..d277f0384 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,5 @@ Meta *.bkp Makevars Makevars.* -*.json *.gcda *.gcno diff --git a/DESCRIPTION b/DESCRIPTION index 66f8795ec..45d2c81ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sits Type: Package -Version: 0.14.0-2 +Version: 0.14.1 Title: Satellite Image Time Series Analysis for Remote Sensing Data Cubes Authors@R: c(person('Rolf', 'Simoes', role = c('aut'), email = 'rolf.simoes@inpe.br'), person('Gilberto', 'Camara', role = c('aut', 'cre'), email = 'gilberto.camara@inpe.br'), @@ -156,6 +156,7 @@ Collate: 'sits_source_api_deafrica.R' 'sits_source_api_local.R' 'sits_source_api_probs.R' + 'sits_source_api_opendata.R' 'sits_source_api_satveg.R' 'sits_source_api_stac.R' 'sits_source_api_usgs.R' diff --git a/NAMESPACE b/NAMESPACE index fb9340f6f..0d634682a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,8 @@ S3method("sits_bands<-",predicted) S3method("sits_bands<-",sits) S3method("sits_labels<-",pattern) S3method("sits_labels<-",sits) +S3method(.gc_format_col,aws_cube) +S3method(.gc_format_col,opendata_cube) S3method(.raster_check_package,default) S3method(.raster_check_package,raster) S3method(.raster_check_package,terra) @@ -74,18 +76,22 @@ S3method(.source_cube,wtss_cube) S3method(.source_item_get_bands,aws_cube) S3method(.source_item_get_bands,bdc_cube) S3method(.source_item_get_bands,deafrica_cube) +S3method(.source_item_get_bands,opendata_cube) S3method(.source_item_get_bands,usgs_cube) S3method(.source_item_get_date,aws_cube) S3method(.source_item_get_date,bdc_cube) S3method(.source_item_get_date,deafrica_cube) +S3method(.source_item_get_date,opendata_cube) S3method(.source_item_get_date,usgs_cube) S3method(.source_item_get_hrefs,aws_cube) S3method(.source_item_get_hrefs,bdc_cube) S3method(.source_item_get_hrefs,deafrica_cube) +S3method(.source_item_get_hrefs,opendata_cube) S3method(.source_item_get_hrefs,usgs_cube) S3method(.source_item_get_resolutions,aws_cube) S3method(.source_item_get_resolutions,bdc_cube) S3method(.source_item_get_resolutions,deafrica_cube) +S3method(.source_item_get_resolutions,opendata_cube) S3method(.source_item_get_resolutions,usgs_cube) S3method(.source_items_bands_select,aws_cube) S3method(.source_items_bands_select,stac_cube) @@ -96,27 +102,33 @@ S3method(.source_items_fileinfo,wtss_cube) S3method(.source_items_new,aws_cube) S3method(.source_items_new,bdc_cube) S3method(.source_items_new,deafrica_cube) +S3method(.source_items_new,opendata_cube) S3method(.source_items_new,usgs_cube) S3method(.source_items_new,wtss_cube) S3method(.source_items_tile_get_bbox,aws_cube) S3method(.source_items_tile_get_bbox,bdc_cube) S3method(.source_items_tile_get_bbox,deafrica_cube) +S3method(.source_items_tile_get_bbox,opendata_cube) S3method(.source_items_tile_get_bbox,usgs_cube) S3method(.source_items_tile_get_crs,aws_cube) S3method(.source_items_tile_get_crs,bdc_cube) S3method(.source_items_tile_get_crs,deafrica_cube) +S3method(.source_items_tile_get_crs,opendata_cube) S3method(.source_items_tile_get_crs,usgs_cube) S3method(.source_items_tile_get_name,aws_cube) S3method(.source_items_tile_get_name,bdc_cube) S3method(.source_items_tile_get_name,deafrica_cube) +S3method(.source_items_tile_get_name,opendata_cube) S3method(.source_items_tile_get_name,usgs_cube) S3method(.source_items_tile_get_size,aws_cube) S3method(.source_items_tile_get_size,bdc_cube) S3method(.source_items_tile_get_size,deafrica_cube) +S3method(.source_items_tile_get_size,opendata_cube) S3method(.source_items_tile_get_size,usgs_cube) S3method(.source_items_tiles_group,aws_cube) S3method(.source_items_tiles_group,bdc_cube) S3method(.source_items_tiles_group,deafrica_cube) +S3method(.source_items_tiles_group,opendata_cube) S3method(.source_items_tiles_group,usgs_cube) S3method(plot,classified_image) S3method(plot,keras_model) @@ -144,6 +156,7 @@ S3method(sits_cube,bdc_cube) S3method(sits_cube,deafrica_cube) S3method(sits_cube,default) S3method(sits_cube,local_cube) +S3method(sits_cube,opendata_cube) S3method(sits_cube,probs_cube) S3method(sits_cube,satveg_cube) S3method(sits_cube,wtss_cube) @@ -216,6 +229,7 @@ export(sits_labels) export(sits_labels_summary) export(sits_lda) export(sits_linear_interp) +export(sits_list_collections) export(sits_merge) export(sits_metadata_to_csv) export(sits_missing_values) diff --git a/NEWS.md b/NEWS.md index 02352a30f..4439b6348 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,25 @@ We are preparing to release the package on CRAN and are making relevant changes in the development version. +# What's new in SITS version 0.14.1 + +### New features in SITS version 0.14.1 + +* Implement new function `sits_list_collections()` +* Update gdalcubes parameters +* Implement `.source_bands_resampling()` +* Remove name from demo file +* Improve `sits_som_clean_samples()` function +* Improve `sits_bands<-()` function +* Improve `sits_select()` function +* Error in cloud band of CBERS4 data example +* Include a function to list collections available in cloud services +* sits_cube_copy() does not include information on the tile +* Get spatial resolution from config file +* Fix partial merge configuration file +* Change bbox to roi in sits + + # What's new in SITS version 0.14.0 ### New features in SITS version 0.14.0-2 diff --git a/R/sits_bands.R b/R/sits_bands.R index 839a6136b..09ee2ba60 100644 --- a/R/sits_bands.R +++ b/R/sits_bands.R @@ -35,7 +35,7 @@ sits_bands <- function(x) { #' sits_bands.sits <- function(x) { - return(names(sits_time_series(x))[-1]) + return(setdiff(names(sits_time_series(x)), "Index")) } #' @export diff --git a/R/sits_bands_set.R b/R/sits_bands_set.R index 0cb872d92..4b21b2dbe 100644 --- a/R/sits_bands_set.R +++ b/R/sits_bands_set.R @@ -21,23 +21,38 @@ # set caller to show in errors .check_set_caller("sits_bands") - # get the time series - ts <- sits_time_series(x) - .check_that( - x = ncol(ts) == length(value) + 1, - msg = "invalid number of bands to be replaced") + # get the data bands + data_bands <- sits_bands(x) - # change band names for all rows of the tibble - rows <- slider::slide(x, function(row) { - ts <- sits_time_series(row) - names(ts) <- c("Index", value) - row$time_series[[1]] <- ts - return(row) - }) - x <- dplyr::bind_rows(rows) + .check_chr(value, allow_empty = FALSE, len_min = length(data_bands), + len_max = length(data_bands), + msg = "Invalid bands values to be replaced") + + # create an row_id to use later in nest + x[["..row_id"]] <- seq_len(nrow(x)) + + # unnest bands + x <- tidyr::unnest(x, cols = "time_series") + + # here, you could pass a function to process fast + new_bands <- colnames(x) + names(new_bands) <- new_bands + + new_bands[data_bands] <- toupper(value) + colnames(x) <- unname(new_bands) + + # nest again + x <- tidyr::nest(x, time_series = c("Index", toupper(value))) + + # remove ..row_id + x <- dplyr::select(x, -"..row_id") + + # set sits tibble class + class(x) <- c("sits", class(x)) return(x) } + #' @export #' `sits_bands<-.cube` <- function(x, value) { diff --git a/R/sits_classification.R b/R/sits_classification.R index 32a729f1e..38aea60c2 100644 --- a/R/sits_classification.R +++ b/R/sits_classification.R @@ -54,7 +54,7 @@ #' 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", "lon_min", "lon_max") +#' named lat/long values ("lon_min", "lat_min", "lon_max", "lat_max") #' #' The "filter_fn" parameter specifies a smoothing filter to be applied to #' time series for reducing noise. Currently, options include diff --git a/R/sits_config.R b/R/sits_config.R index 60e3da73a..30e37cf53 100644 --- a/R/sits_config.R +++ b/R/sits_config.R @@ -13,9 +13,13 @@ #' #' \code{sits_config_show()} prints the current sits #' configuration options. To show specific configuration options for -#' a source, a collection, or a palette, user can inform the corresponding +#' a source, a collection, or a palette, users can inform the corresponding #' keys to \code{source}, \code{collection}, and \code{palette} parameters. #' +#' \code{sits_list_collections()} prints the collections available +#' in each cloud service supported by sits. Users can select to get information +#' only for a single service by using the \code{source} parameter. +#' #' @param processing_bloat A \code{numeric} value to estimate #' growth size of R memory relative to block size. #' @param rstac_pagination_limit A \code{numeric} value indicating number of @@ -81,6 +85,9 @@ sits_config <- function(processing_bloat = NULL, message(paste("Additional configurations found in", user_yml_file)) config <- yaml::yaml.load_file(input = user_yml_file, merge.precedence = "override") + config <- utils::modifyList(sits_env[["config"]], + config, + keep.null = FALSE) # set options defined by user (via YAML file) # modifying existing configuration @@ -190,6 +197,49 @@ sits_config_show <- function(source = NULL, return(invisible(config)) } +#' @rdname sits_configuration +#' +#' @return +#' \code{sits_list_collections()} prints the collections available in +#' each cloud service supported by sits. +#' +#' @export +sits_list_collections <- function(source = NULL) { + + # get sources available + sources <- .sources(internal = FALSE) + + # if the user has required a source + # check that it is valid + if (!purrr::is_null(source)) { + # check if source exists + .check_chr_within( + x = source, + within = sources, + msg = "invalid source value" + ) + sources <- source + } + + purrr::map(sources, function(s){ + + cat(paste0(s, ":\n")) + collections <- .source_collections(source = s) + purrr::map(collections, function(c){ + # get collection information + + cat(paste0("- ", c)) + cat(paste0(" (", .source_collection_satellite(s, c), + "/", .source_collection_sensor(s, c), ")\n")) + cat("- bands: ") + cat(.source_bands(s, c)) + cat("\n") + cat("\n") + }) + }) + return(invisible(NULL)) +} + .config_set_options <- function(processing_bloat = NULL, rstac_pagination_limit = NULL, raster_api_package = NULL, diff --git a/R/sits_cube.R b/R/sits_cube.R index 2bb9bc8d3..7f17df165 100755 --- a/R/sits_cube.R +++ b/R/sits_cube.R @@ -95,7 +95,7 @@ #' @param bands Bands to be included. #' @param tiles Tiles from the collection to be included in the #' data cube. -#' @param bbox Area of interest (see details below). +#' @param roi Region of interest (see details below). #' @param start_date Initial date for the cube (optional). #' @param end_date Final date for the cube (optional). #' @param s2_resolution Resolution of S2 images ("10m", "20m" or "60m"). @@ -114,8 +114,8 @@ #' probabilities). #' @param probs_labels Labels associated to a probabilities cube. #' -#' @details The \code{bbox} parameter allows a selection of an area of interest. -#' Either using a named \code{vector} ("xmin", "ymin", "xmax", "ymax") with +#' @details The \code{roi} parameter allows a selection of an area of interest. +#' Either using a named \code{vector} ("lon_min", "lat_min", "lon_max", "lat_max") with #' values in WGS 84, a \code{sfc} or \code{sf} object from sf package, or a #' GeoJSON geometry (RFC 7946). Note that this parameter does not crop a #' region, but only selects the images that intersect with it. @@ -186,14 +186,14 @@ #' s2_resolution = 20 #' ) #' -#' # --- Create a cube based on a stack of CBERS data -#' data_dir <- system.file("extdata/raster/cbers", package = "sits") +#' # --- Create a cube based on a local MODIS data +#' data_dir <- system.file("extdata/raster/mod13q1", package = "sits") #' -#' cbers_cube <- sits_cube( +#' modis_cube <- sits_cube( #' source = "LOCAL", -#' name = "022024", +#' name = "modis_sinop", #' origin = "BDC", -#' collection = "CB4_64-1", +#' collection = "MOD13Q1-6", #' data_dir = data_dir, #' delim = "_", #' parse_info = c("X1", "X2", "tile", "band", "date") @@ -272,7 +272,7 @@ sits_cube.bdc_cube <- function(source = "BDC", ..., collection, bands = NULL, tiles = NULL, - bbox = NULL, + roi = NULL, start_date = NULL, end_date = NULL) { @@ -305,7 +305,7 @@ sits_cube.bdc_cube <- function(source = "BDC", ..., name = name, bands = bands, tiles = tiles, - bbox = bbox, + bbox = roi, start_date = start_date, end_date = end_date, ...) } @@ -319,7 +319,7 @@ sits_cube.deafrica_cube <- function(source = "DEAFRICA", ..., collection = "S2_L2A", bands = NULL, tiles = NULL, - bbox = NULL, + roi = NULL, start_date = NULL, end_date = NULL) { @@ -354,7 +354,7 @@ sits_cube.deafrica_cube <- function(source = "DEAFRICA", ..., name = name, bands = bands, tiles = tiles, - bbox = bbox, + bbox = roi, start_date = start_date, end_date = end_date, ...) } @@ -368,7 +368,7 @@ sits_cube.aws_cube <- function(source = "AWS", ..., collection = "sentinel-s2-l2a", tiles = NULL, bands = NULL, - bbox = NULL, + roi = NULL, s2_resolution = 20, start_date = NULL, end_date = NULL) { @@ -415,12 +415,58 @@ sits_cube.aws_cube <- function(source = "AWS", ..., name = name, bands = bands, tiles = tiles, - bbox = bbox, + bbox = roi, start_date = start_date, end_date = end_date, ..., s2_resolution = s2_resolution) } +#' @rdname sits_cube +#' +#' @export +sits_cube.opendata_cube <- function(source = "OPENDATA", ..., + name = "opendata_cube", + url = NULL, + collection = "sentinel-s2-l2a-cogs", + tiles = NULL, + bands = NULL, + roi = NULL, + start_date = NULL, + end_date = NULL) { + + + # collection name is upper case + collection <- toupper(collection) + + # suite of checks to verify collection parameter + .check_collection(source = source, + collection = collection) + + if (is.null(bands)) + bands <- .source_bands(source = source, + collection = collection) + + # Pre-condition - checks if the bands are supported by the collection + .check_bands(source = source, + collection = collection, + bands = bands) + + # dry run to verify if service is running + .source_access_test(source = source, + collection = collection, ..., + bands = bands) + + # builds a sits data cube + .source_cube(source = source, + collection = collection, + name = name, + bands = bands, + tiles = tiles, + bbox = roi, + start_date = start_date, + end_date = end_date, ...) +} + #' @rdname sits_cube #' @keywords internal sits_cube.usgs_cube <- function(source = "USGS", ..., @@ -429,7 +475,7 @@ sits_cube.usgs_cube <- function(source = "USGS", ..., collection = "landsat-c2l2-sr", tiles = NULL, bands = NULL, - bbox = NULL, + roi = NULL, start_date = NULL, end_date = NULL) { @@ -471,7 +517,7 @@ sits_cube.usgs_cube <- function(source = "USGS", ..., name = name, bands = bands, tiles = tiles, - bbox = bbox, + bbox = roi, start_date = start_date, end_date = end_date, ...) } @@ -595,20 +641,20 @@ sits_cube.default <- function(source, ...) { #' #' @examples #' \donttest{ -#' data_dir <- system.file("extdata/raster/cbers", package = "sits") +#' data_dir <- system.file("extdata/raster/mod13q1", package = "sits") #' -#' cbers_022024 <- sits_cube( +#' modis_cube <- sits_cube( #' source = "LOCAL", -#' name = "cbers_022024", +#' name = "modis_sinop", #' origin = "BDC", -#' collection = "CB4_64-1", +#' collection = "MOD13Q1-6", #' band = "NDVI", #' data_dir = data_dir, #' parse_info = c("X1", "X2", "tile", "band", "date") #' ) #' -#' cbers_022024_copy <- sits_cube_copy(cbers_022024, -#' name = "cb_022024_cp", +#' modis_cube_copy <- sits_cube_copy(modis_cube, +#' name = "modis_sinop_cp", #' dest_dir = tempdir() #' ) #' } @@ -665,8 +711,10 @@ sits_cube_copy <- function(cube, # get all the bands which are requested file_info_out <- dplyr::filter(file_info, band %in% bands) + # remove token (if existing) + file_no_token <- gsub("^([^?]+)(\\?.*)?$", "\\1", file_info_out$path[[1]]) # get the file extension - file_ext <- tools::file_ext(file_info_out$path[1]) + file_ext <- tools::file_ext(file_no_token) if (file_ext == "jp2") { gdal_of <- "JP2OpenJPEG" @@ -680,6 +728,7 @@ sits_cube_copy <- function(cube, dest_dir, "/", row$satellite, "_", row$sensor, "_", + row$tile,"_", file_row$band, "_", file_row$date, ".", file_ext @@ -1304,7 +1353,7 @@ NULL .source_bands_to_sits(source = source, collection = collection, bands = bands), - collapse = ", ")), + collapse = ", ")), call. = FALSE) return(invisible(NULL)) diff --git a/R/sits_gdalcubes.R b/R/sits_gdalcubes.R index 14fc82c2b..a84dd2421 100644 --- a/R/sits_gdalcubes.R +++ b/R/sits_gdalcubes.R @@ -1,5 +1,5 @@ #' @title Save the images based on an aggregation method. -#' @name .sits_gc_compose +#' @name .gc_new_cube #' @keywords internal #' #' @param tile A data cube tile @@ -9,8 +9,8 @@ #' @param cv A \code{list} 'cube_view' with values from cube. #' @param cloud_mask A \code{logical} corresponds to the use of the cloud band #' for aggregation. -#' @param db_file Database to be created by gdalcubes -#' @param dir_images Directory where the aggregated images will be written. +#' @param path_db Database to be created by gdalcubes +#' @param output_dir Directory where the aggregated images will be written. #' @param cloud_mask A \code{logical} corresponds to the use of the cloud band #' for aggregation. #' @param ... Additional parameters that can be included. See @@ -18,93 +18,82 @@ #' @param version A \code{character} with version of the output files. #' #' @return A data cube tile with information used in its creation. -.sits_gc_compose <- function(tile, - name, - cv, - img_col, - db_file, - dir_images, - cloud_mask, ..., - version = "v1") { +.gc_new_cube <- function(tile, + name, + cv, + img_col, + path_db, + output_dir, + cloud_mask, ..., + version = "v1") { # set caller to show in errors - .check_set_caller(".sits_gc_compose") - - .check_that( - x = nrow(tile) == 1, - msg = "tile must have only one row." - ) - - # verifies the path to save the images - .check_that( - x = dir.exists(dir_images), - msg = "The provided dir does not exist. Please provided a valid path." - ) + .check_set_caller(".gc_new_cube") # create a clone cube cube_gc <- .sits_cube_clone( cube = tile, name = name, ext = "", - output_dir = dir_images, - version = version) + output_dir = output_dir, + version = version + ) - # delete file info column - cube_gc$file_info <- NULL + # update cube metadata + cube_gc <- .gc_update_metadata(cube = cube_gc, cube_view = cv) # create file info column - file_info <- tibble::tibble(band = character(), - date = lubridate::as_date(""), - res = numeric(), - path = character()) - # add file info and path db columns - cube_gc <- tibble::add_column(cube_gc, file_info = list(file_info)) - - for (band in .cube_bands(tile)) { - # create a raster_cube object from gdalcubes - cube_brick <- .sits_gc_brick(tile, img_col, cv, cloud_mask) - - band_source <- .source_bands_to_source( - source = .cube_source(tile), - collection = .cube_collection(tile), - bands = band - ) + cube_gc$file_info[[1]] <- tibble::tibble(band = character(), + date = lubridate::as_date(""), + res = numeric(), + path = character()) + + for (band in .cube_bands(tile, add_cloud = FALSE)) { + - message(paste("Writing images of band", band, "of tile", - tile$tile)) + cv$resampling <- .source_bands_resampling(source = tile$source, + collection = tile$collection, + bands = band) + + # create a raster_cube object to each band the select below change + # the object value + cube_brick <- .gc_raster_cube(tile, img_col, cv, cloud_mask) + + message(paste("Writing images of band", band, "of tile", tile$tile)) # write the aggregated cubes path_write <- gdalcubes::write_tif( - gdalcubes::select_bands(cube_brick, band_source), - dir = dir_images, + gdalcubes::select_bands(cube_brick, band), + dir = output_dir, prefix = paste("cube", tile$tile, band, "", sep = "_"), + creation_options = list("COMPRESS" = "LZW", "BIGTIFF" = "YES"), write_json_descr = TRUE, ...) # retrieving image date - images_date <- .sits_gc_date(path_write) - res <- dplyr::filter(tile$file_info[[1]], band == band)$res[[1]] + images_date <- .gc_get_date(path_write) # set file info values cube_gc$file_info[[1]] <- tibble::add_row( cube_gc$file_info[[1]], band = rep(band, length(path_write)), date = images_date, - res = rep(res, length(path_write)), + res = rep(cv$space$dx, length(path_write)), path = path_write ) } return(cube_gc) } + #' @title Extracted date from aggregated cubes -#' @name .sits_gc_date +#' @name .gc_get_date #' @keywords internal #' #' @param dir_images A \code{character} corresponds to the path on which the #' images will be saved. #' #' @return a \code{character} vector with the dates extracted. -.sits_gc_date <- function(dir_images) { +.gc_get_date <- function(dir_images) { # get image name image_name <- basename(dir_images) @@ -127,8 +116,9 @@ return(date_files) } + #' @title Create a raster_cube object -#' @name .sits_gc_brick +#' @name .gc_raster_cube #' @keywords internal #' #' @param cube Data cube from where data is to be retrieved. @@ -140,7 +130,7 @@ #' #' @return a \code{object} 'raster_cube' from gdalcubes containing information #' about the cube brick metadata. -.sits_gc_brick <- function(cube, img_col, cv, cloud_mask) { +.gc_raster_cube <- function(cube, img_col, cv, cloud_mask) { # defining the chunk size c_size <- c(t = 1, @@ -149,7 +139,7 @@ mask_band <- NULL if (cloud_mask) - mask_band <- .sits_gc_cloud_mask(cube) + mask_band <- .gc_cloud_mask(cube) # create a brick of raster_cube object cube_brick <- gdalcubes::raster_cube(image_collection = img_col, @@ -159,15 +149,37 @@ return(cube_brick) } + +#' @title Update metadata from sits cube using gdalcubes metadata +#' @name .gc_update_metadata +#' @keywords internal +#' +#' @param cube Data cube from where data is to be retrieved. +#' @param cv A \code{object} 'cube_view' with values from cube. +#' for aggregation. +#' +#' @return a \code{sits_cube} object with updated metadata. +.gc_update_metadata <- function(cube, cube_view) { + + # update bbox + bbox_names <- c("xmin", "xmax", "ymin", "ymax") + cube[, bbox_names] <- cube_view$space[c("left", "right", "bottom", "top")] + + # update nrows and ncols + cube[, c("nrows", "ncols")] <- cube_view$space[c("ny", "nx")] + + return(cube) +} + #' @title Create an object image_mask with information about mask band -#' @name .sits_gc_cloud_mask +#' @name .gc_cloud_mask #' @keywords internal #' #' @param tile Data cube tile from where data is to be retrieved. #' #' @return A \code{object} 'image_mask' from gdalcubes containing information #' about the mask band. -.sits_gc_cloud_mask <- function(tile) { +.gc_cloud_mask <- function(tile) { bands <- .cube_bands(tile) cloud_band <- .source_cloud() @@ -181,14 +193,9 @@ "mask, please include the cloud band in your cube") ) - cloud_source <- .source_bands_to_source( - source = .cube_source(cube = tile), - collection = .cube_collection(cube = tile), - bands = cloud_band) - # create a image mask object mask_values <- gdalcubes::image_mask( - cloud_source, + cloud_band, values = .source_cloud_interp_values( source = .cube_source(cube = tile), collection = .cube_collection(cube = tile) @@ -197,8 +204,9 @@ return(mask_values) } + #' @title Create an image_collection object -#' @name .sits_gc_database +#' @name .gc_create_database #' @keywords internal #' #' @param cube Data cube from where data is to be retrieved. @@ -207,54 +215,90 @@ #' #' @return a \code{object} 'image_collection' containing information about the #' images metadata. -.sits_gc_database <- function(cube, path_db) { +.gc_create_database <- function(cube, path_db) { # set caller to show in errors - .check_set_caller(".sits_gc_database") - - # error if a cube other than S2_L2A_AWS is provided - .check_that( - x = .sits_cube_source(cube) == "AWS", - msg = "for now, only 'AWS' cubes can be aggregated." - ) + .check_set_caller(".gc_create_database") # joining the bands of all tiles - full_images <- dplyr::bind_rows(cube$file_info) + file_info <- dplyr::bind_rows(cube$file_info) - # retrieving the s2_la_aws format - format_col <- system.file("extdata/gdalcubes/s2la_aws.json", - package = "sits") + # retrieving the collection format + format_col <- .gc_format_col(cube$source) message("Creating database of images...") - # create image collection cube - ic_cube <- gdalcubes::create_image_collection(files = full_images$path, - format = format_col, - out_file = path_db) + ic_cube <- gdalcubes::create_image_collection( + files = file_info$path, + format = format_col, + out_file = path_db) return(ic_cube) } + + +#' @title Internal function to handle with different file collection formats +#' for each provider. +#' @name gdalcubes_format_col +#' @keywords internal +#' +#' @description +#' Generic function with the goal that each source implements its own way of +#' localizing the collection format file. +#' +#' @param source A \code{character} value referring to a valid data source. +#' @param ... Additional parameters. +#' +#' @return A \code{character} path with format collection. +.gc_format_col <- function(source, ...) { + + # set caller to show in errors + .check_set_caller("sits_cube") + + s <- .source_new(source = source) + + # Dispatch + UseMethod(".gc_format_col", s) +} + +#' @keywords internal +#' @export +.gc_format_col.aws_cube <- function(source, ...) { + + system.file("extdata/gdalcubes/s2la_aws.json", package = "sits") +} + +#' @keywords internal +#' @export +.gc_format_col.opendata_cube <- function(source, ...) { + + system.file("extdata/gdalcubes/s2la_aws_cogs.json", package = "sits") +} + #' @title Create a cube_view object -#' @name .sits_gc_cube +#' @name .gc_create_cube_view #' @keywords internal #' #' @param tile A data cube tile #' @param period A \code{character} with the 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". +#' @param res A \code{numeric} with spatial resolution of the image that +#' will be aggregated. #' @param roi A region of interest. #' @param toi A timeline of intersection #' @param agg_method A \code{character} with the method that will be applied in #' the aggregation, the following are available: "min", "max", "mean", #' "median" or "first". -#' @param resampling A \code{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). #' #' @return a \code{cube_view} object from gdalcubes. -.sits_gc_cube <- function(tile, period, roi, toi, agg_method, resampling) { +.gc_create_cube_view <- function(tile, + period, + res, + roi, + toi, + agg_method) { # set caller to show in errors - .check_set_caller(".sits_gc_cube") + .check_set_caller(".gc_create_cube_view") .check_that( x = nrow(tile) == 1, @@ -271,6 +315,18 @@ msg = "the parameter 'method' must be provided." ) + .check_num( + x = res, + msg = "the parameter 'res' is invalid.", + allow_null = TRUE, + len_max = 1 + ) + + if (is.null(res)) + res <- tile[["xres"]][[1]] + + bbox_roi <- sits_bbox(tile) + if (!purrr::is_null(roi)) { bbox_roi <- .sits_roi_bbox(roi, tile) @@ -279,13 +335,12 @@ right = bbox_roi[["xmax"]], bottom = bbox_roi[["ymin"]], top = bbox_roi[["ymax"]]) - } else { - bbox_roi <- sits_bbox(tile) + } else roi <- list(left = bbox_roi[["xmin"]], right = bbox_roi[["xmax"]], bottom = bbox_roi[["ymin"]], top = bbox_roi[["ymax"]]) - } + # create a list of cube view cv <- gdalcubes::cube_view( @@ -296,11 +351,10 @@ t0 = format(toi[["max_min_date"]], "%Y-%m-%d"), t1 = format(toi[["min_max_date"]], "%Y-%m-%d")), srs = tile$crs[[1]], - dt = period, - dx = tile$xres[[1]], - dy = tile$yres[[1]], - aggregation = agg_method, - resampling = resampling + dt = period, + dx = res, + dy = res, + aggregation = agg_method ) return(cv) diff --git a/R/sits_get_data.R b/R/sits_get_data.R index 61ceb08e8..c8a8704bb 100644 --- a/R/sits_get_data.R +++ b/R/sits_get_data.R @@ -128,7 +128,8 @@ sits_get_data.wtss_cube <- function(cube, file = NULL, ..., start_date = NULL, end_date = NULL, bands = NULL, - label = "NoClass") { + label = "NoClass", + impute_fn = sits_impute_linear()) { # Precondition - lat/long must be provided .check_that(!purrr::is_null(latitude) & @@ -146,10 +147,11 @@ sits_get_data.wtss_cube <- function(cube, file = NULL, ..., cube = cube, longitude = longitude, latitude = latitude, - start_date = start_end["start_date"], - end_date = start_end["end_date"], + start_date = start_end[["start_date"]], + end_date = start_end[["end_date"]], bands = bands, - label = label + label = label, + impute_fn = impute_fn ) if (!purrr::is_null(data) && !("sits" %in% class(data))) { class(data) <- c("sits", class(data)) @@ -201,7 +203,10 @@ sits_get_data.satveg_cube <- function(cube, #' #' @export #' -sits_get_data.csv_wtss_cube <- function(cube, file, ..., bands = NULL) { +sits_get_data.csv_wtss_cube <- function(cube, + file, ..., + bands = NULL, + impute_fn = sits_impute_linear()) { # read sample information from CSV file and put it in a tibble csv <- tibble::as_tibble(utils::read.csv(file)) @@ -229,7 +234,8 @@ sits_get_data.csv_wtss_cube <- function(cube, file, ..., bands = NULL) { start_date = lubridate::as_date(start_date), end_date = lubridate::as_date(end_date), bands = bands, - label = label + label = label, + impute_fn = impute_fn ) return(row) } @@ -310,6 +316,7 @@ sits_get_data.shp_wtss_cube <- function(cube, file, ..., end_date = NULL, bands = NULL, label = "NoClass", + impute_fn = sits_impute_linear(), shp_attr = NULL, .n_shp_pol = 30) { @@ -346,7 +353,8 @@ sits_get_data.shp_wtss_cube <- function(cube, file, ..., start_date = start_end["start_date"], end_date = start_end["end_date"], bands = bands, - label = lab + label = lab, + impute_fn = impute_fn ) return(row) } @@ -445,8 +453,8 @@ sits_get_data.raster_cube <- function(cube, file = NULL, ..., id = 1, longitude = longitude, latitude = latitude, - start_date = start_end["start_date"], - end_date = start_end["end_date"], + start_date = start_end[["start_date"]], + end_date = start_end[["end_date"]], label = label ) @@ -742,7 +750,8 @@ sits_get_data.shp_raster_cube <- function(cube, file, ..., start_date = NULL, end_date = NULL, bands = NULL, - label = "NoClass") { + label = "NoClass", + impute_fn = sits_impute_linear()) { # verifies if wtss package is installed if (!requireNamespace("Rwtss", quietly = TRUE)) { @@ -786,6 +795,106 @@ sits_get_data.shp_raster_cube <- function(cube, file, ..., paste(e) }) + # interpolate clouds + cld_band <- .source_bands_band_name(source = "WTSS", + collection = cube$collection, + bands = .source_cloud()) + + # retrieve values for the cloud band (if available) + if (cld_band %in% bands) { + + bands <- bands[bands != cld_band] + + # retrieve values that indicate clouds + cld_index <- .source_cloud_interp_values( + source = .cube_source(cube = cube), + collection = .cube_collection(cube = cube) + ) + + # get the values of the time series (terra object) + cld_values <- as.integer(ts$time_series[[1]][[cld_band]]) + + # get information about cloud bitmask + if (.source_cloud_bit_mask( + source = .cube_source(cube = cube), + collection = .cube_collection(cube = cube))) { + + cld_values <- as.matrix(cld_values) + cld_rows <- nrow(cld_values) + cld_values <- matrix(bitwAnd(cld_values, sum(2 ^ cld_index)), + nrow = cld_rows) + } + } + + # Retrieve values on a band by band basis + ts_bands <- lapply(bands, function(band) { + + # get the values of the time series as matrix + values_band <- ts$time_series[[1]][[band]] + + # convert to sits band + band_sits <- .source_bands_to_sits(source = cube$source[[1]], + collection = cube$collection[[1]], + bands = band) + + if (!purrr::is_null(impute_fn)) { + + # get the scale factors, max, min and missing values + missing_value <- .cube_band_missing_value( + cube = cube, + band = band_sits + ) + minimum_value <- .cube_band_minimum_value( + cube = cube, + band = band_sits + ) + maximum_value <- .cube_band_maximum_value( + cube = cube, + band = band_sits + ) + scale_factor <- .cube_band_scale_factor( + cube = cube, + band = band_sits + ) + + # include information from cloud band + if (!purrr::is_null(cld_band)) { + if (.source_cloud_bit_mask( + source = .cube_source(cube = cube), + collection = .cube_collection(cube = cube))) + values_band[cld_values > 0] <- NA + else + values_band[cld_values %in% cld_index] <- NA + } + + # adjust maximum and minimum values + values_band[values_band < minimum_value * scale_factor] <- NA + values_band[values_band > maximum_value * scale_factor] <- NA + + # are there NA values? interpolate them + if (any(is.na(values_band))) { + values_band <- impute_fn(as.integer(values_band / scale_factor)) + } + } + + # return the values + return(values_band * scale_factor) + }) + + # rename bands to sits band names + bands_sits <- .source_bands_to_sits(source = cube$source[[1]], + collection = cube$collection[[1]], + bands = bands) + + # now we have to transpose the data + ts_samples <- ts_bands %>% + purrr::set_names(bands_sits) %>% + tibble::as_tibble() + + ts_samples <- dplyr::bind_cols(ts$time_series[[1]]["Index"], ts_samples) + + ts$time_series[[1]] <- ts_samples + # change the class of the data # before - class "wtss" # now - class "sits" @@ -800,6 +909,7 @@ sits_get_data.shp_raster_cube <- function(cube, file, ..., ts <- .sits_tibble_rename(ts) # band names are uppercase in SITS } + # return the tibble with the time series return(ts) } diff --git a/R/sits_raster_data.R b/R/sits_raster_data.R index 8b500f4e4..1bc112fac 100644 --- a/R/sits_raster_data.R +++ b/R/sits_raster_data.R @@ -328,8 +328,11 @@ ) # get the values of the time series (terra object) - cld_values <- .sits_cube_extract(cube = cube, band_cube = cld_band, - xy = xy) + cld_values <- .sits_cube_extract( + cube = cube, + band_cube = cld_band, + xy = xy + ) # get information about cloud bitmask if (.source_cloud_bit_mask( diff --git a/R/sits_regularize.R b/R/sits_regularize.R index eb489d8a1..68fcb7264 100644 --- a/R/sits_regularize.R +++ b/R/sits_regularize.R @@ -44,28 +44,32 @@ #' } #' } #' -#' @param cube A cube whose spacing of observation times is -#' not constant and will be regularized by the -#' "gdalcubes" packges -#' @param name Name of the output data cube -#' @param dir_images Directory where the regularized images will be -#' written by \code{gdalcubes}. -#' @param period ISO8601 time period for regular data cubes -#' produced by \code{gdalcubes}, -#' with number and unit, e.g., "P16D" for 16 days. -#' Use "D", "M" and "Y" for days, month and year.. -#' -#' @param roi A region of interest (see above) -#' @param agg_method Method that will be applied by \code{gdalcubes} -#' for aggregation. Options: "min", "max", "mean", -#' "median" and "first". -#' @param resampling Method to be used by \code{gdalcubes} -#' for resampling in mosaic operation. -#' Options: "near", "bilinear", "bicubic" -#' or others supported by gdalwarp -#' (see https://gdal.org/programs/gdalwarp.html). -#' @param cloud_mask Use cloud band for aggregation by \code{gdalcubes}? -#' +#' @param cube A \code{sits_cube} object whose spacing of observation +#' times is not constant and will be regularized by the \code{gdalcubes} +#' package. +#' @param name A \code{character} with name of the output data cube +#' @param output_dir A \code{character} with a directory where the regularized +#' images will be written by \code{gdalcubes}. +#' @param period A \code{character} with ISO8601 time period for regular +#' data cubes produced by \code{gdalcubes}, with number and unit, e.g., "P16D" +#' for 16 days. Use "D", "M" and "Y" for days, month and year. +#' @param res A \code{numeric} with spatial resolution of the image that +#' will be aggregated. +#' @param roi A named \code{numeric} vector with a region of interest. +#' See above +#' @param multicores A \code{numeric} with the number of cores will be used in +#' the regularize. By default is used 1 core. +#' @param agg_method A \code{character} with method that will be applied by +#' \code{gdalcubes} for aggregation. +#' Options: \code{min}, \code{max}, \code{mean}, \code{median} and +#' \code{first}. +#' @param resampling A \code{character} with method to be used by +#' \code{gdalcubes} for resampling in mosaic operation. +#' Options: \code{near}, \code{bilinear}, \code{bicubic} or others supported by +#' gdalwarp (see https://gdal.org/programs/gdalwarp.html). +#' By default is bilinear. +#' @param cloud_mask A \code{logical} to use cloud band for aggregation by +#' \code{gdalcubes}. Default is \code{TRUE}. #' #' @note #' The "roi" parameter defines a region of interest. It can be @@ -73,16 +77,18 @@ #' named XY values ("xmin", "xmax", "ymin", "ymax") or #' named lat/long values ("lat_min", "lat_max", "long_min", "long_max") #' -#' @export +#' @return A \code{sits_cube} object with aggregated images. #' +#' @export sits_regularize <- function(cube, name, - dir_images, + output_dir, period = NULL, + res = NULL, roi = NULL, agg_method = NULL, - resampling = "bilinear", - cloud_mask = TRUE) { + cloud_mask = TRUE, + multicores = 1) { # set caller to show in errors .check_set_caller("sits_regularize") @@ -94,6 +100,24 @@ sits_regularize <- function(cube, ) } + # supported cubes + .check_chr_within( + x = .sits_cube_source(cube), + within = c("AWS", "OPENDATA"), + msg = paste("for the time being only the 'AWS' and 'OPENDATA' cubes", + "can be regularized.") + ) + + .check_num( + x = multicores, + allow_zero = FALSE, + min = 1, + msg = "invalid 'multicores' parameter." + ) + + # setting in global env multicores options + gdalcubes::gdalcubes_options(threads = multicores) + # test if provided object its a sits cube .check_that( x = inherits(cube, "raster_cube"), @@ -103,7 +127,15 @@ sits_regularize <- function(cube, ) # fix slashes for windows - dir_images <- normalizePath(dir_images) + output_dir <- normalizePath(output_dir) + + # verifies the path to save the images + .check_that( + x = dir.exists(output_dir), + msg = "Invalid 'output_dir' parameter.." + ) + + path_db <- paste0(output_dir, "/gdalcubes.db") # filter only intersecting tiles intersects <- slider::slide_lgl(cube, @@ -145,31 +177,33 @@ sits_regularize <- function(cube, cube <- .sits_cube_fix_name(cube) # create an image collection - db_file <- paste0(dir_images, "/gdalcubes.db") - img_col <- .sits_gc_database(cube = cube, path_db = db_file) + img_col <- .gc_create_database(cube = cube, path_db = path_db) gc_cube <- slider::slide_dfr(cube, function(tile){ # create a list of cube view object - cv <- .sits_gc_cube(tile = tile, - period = period, - roi = roi, - toi = toi, - agg_method = agg_method, - resampling = resampling) + cv <- .gc_create_cube_view(tile = tile, + period = period, + roi = roi, + res = res, + toi = toi, + agg_method = agg_method) # create of the aggregate cubes - gc_tile <- .sits_gc_compose(tile = tile, - name = name, - cv = cv, - img_col = img_col, - db_file = db_file, - dir_images = dir_images, - cloud_mask = cloud_mask) + gc_tile <- .gc_new_cube(tile = tile, + name = name, + cv = cv, + img_col = img_col, + path_db = path_db, + output_dir = output_dir, + cloud_mask = cloud_mask) return(gc_tile) }) + # reset global option + gdalcubes::gdalcubes_options(threads = 1) + class(gc_cube) <- c("raster_cube", class(gc_cube)) return(gc_cube) diff --git a/R/sits_select.R b/R/sits_select.R index f23940c2f..f2f85c796 100644 --- a/R/sits_select.R +++ b/R/sits_select.R @@ -42,24 +42,35 @@ sits_select.sits <- function(data, bands) { # bands names in SITS are uppercase bands <- toupper(bands) sits_bands(data) <- toupper(sits_bands(data)) + data_bands <- sits_bands(data) .check_chr_within( x = bands, within = sits_bands(data), - msg = paste("missing bands:", - paste(bands[!bands %in% sits_bands(data)], - collapse = ", ")) + msg = paste("Invalid bands values") ) - # prepare result sits tibble - result <- data + # make sure that nesting operation (bellow) will be done correctly + data[["..row_id"]] <- seq_len(nrow(data)) - # select the chosen bands for the time series - result$time_series <- data$time_series %>% - purrr::map(function(ts) ts[, c("Index", bands)]) + # unnest bands + data <- tidyr::unnest(data, cols = "time_series") - # return the result - return(result) + # select anything other than non selected bands + removed_bands <- paste0(setdiff(data_bands, bands)) + + data <- data[, setdiff(colnames(data), removed_bands)] + + # nest again + data <- tidyr::nest(data, time_series = dplyr::all_of(c("Index", bands))) + + # remove ..row_id + data <- dplyr::select(data, -"..row_id") + + # set sits tibble class + class(data) <- c("sits", class(data)) + + return(data) } #' @export diff --git a/R/sits_som.R b/R/sits_som.R index 023f25640..886dd1609 100644 --- a/R/sits_som.R +++ b/R/sits_som.R @@ -279,7 +279,6 @@ sits_som_map <- function(data, #' new_samples <- sits_som_clean_samples(som_map) #' } #' @export - sits_som_clean_samples <- function(som_map, prior_threshold = 0.6, posterior_threshold = 0.6, @@ -299,43 +298,23 @@ sits_som_clean_samples <- function(som_map, msg = "invalid keep parameter" ) - # original_samples - data <- som_map$data - - # obtain the evaluation for each sample - eval_lst <- slider::slide(data, function(row) { - neuron_id <- row$id_neuron - sample_probs <- - som_map$labelled_neurons %>% - dplyr::filter(id_neuron == neuron_id) %>% - dplyr::filter(label_samples == row$label) - if (sample_probs$prior_prob >= prior_threshold & - sample_probs$post_prob >= posterior_threshold) { - return("clean") - } else { - if (sample_probs$prior_prob >= prior_threshold & - sample_probs$post_prob < posterior_threshold) { - return("analyze") - } else { - return("remove") - } - } - }) - data$eval <- unlist(eval_lst) - - # obtain the posterior probability for each sample - post_probs <- slider::slide(data, function(row) { - neuron_id <- row$id_neuron - sample_prob <- - som_map$labelled_neurons %>% - dplyr::filter(id_neuron == neuron_id) %>% - dplyr::filter(label_samples == row$label) - - return(sample_prob$post_prob) - }) - data$post_prob <- unlist(post_probs) - - data <- dplyr::filter(data, eval %in% keep) + # function to detect of class noise + .detect_class_noise <- function(prior_prob, post_prob) { + ifelse( + prior_prob >= prior_threshold & + post_prob >= posterior_threshold, "clean", + ifelse( + prior_prob >= prior_threshold & + post_prob < posterior_threshold, "analyze", "remove")) + } + + data <- som_map$data %>% + dplyr::inner_join(som_map$labelled_neurons, + by = c("id_neuron", "label" = "label_samples")) %>% + dplyr::mutate(eval = .detect_class_noise(prior_prob, post_prob)) %>% + dplyr::select(-count, -prior_prob) %>% + dplyr::filter(eval %in% keep) + return(data) } diff --git a/R/sits_source_api.R b/R/sits_source_api.R index 564c1ff42..e478bba98 100644 --- a/R/sits_source_api.R +++ b/R/sits_source_api.R @@ -356,6 +356,45 @@ NULL return(res) } +#' @rdname source_bands +#' +#' @description \code{.source_bands_resampling()} returns the +#' \code{resampling} attribute of all bands filtered by its parameters. +#' +#' @return \code{.source_bands_resampling()} returns a \code{character} +#' vectors with the desired resampling method that should be used in the band. +.source_bands_resampling <- function(source, + collection, ..., + bands = NULL, + fn_filter = NULL, + add_cloud = TRUE) { + + # source is upper case + source <- toupper(source) + + # collection is upper case + collection <- toupper(collection) + + # pre-condition + .source_collection_check(source = source, collection = collection) + + res <- .source_bands_reap(source = source, + collection = collection, + key = "resampling", + bands = bands, + fn_filter = fn_filter, + add_cloud = add_cloud) + + # simplify to character + res <- unlist(res, recursive = FALSE, use.names = FALSE) + + # post-condition + .check_chr(res, allow_empty = FALSE, + msg = "invalid 'resampling' in config file") + + return(res) +} + #' @rdname source_bands #' #' @description \code{.source_bands_to_sits()} converts any bands to its diff --git a/R/sits_source_api_bdc.R b/R/sits_source_api_bdc.R index 6d4299d4f..151c4ddf3 100644 --- a/R/sits_source_api_bdc.R +++ b/R/sits_source_api_bdc.R @@ -34,7 +34,15 @@ .source_item_get_resolutions.bdc_cube <- function(source, item, ..., collection = NULL) { - item[[c("properties", "eo:gsd")]] + + res <- .source_bands_resolutions( + source = source, + collection = collection, + bands = .source_item_get_bands(source = source, + item = item) + ) + + return(res[[1]]) } #' @keywords internal diff --git a/R/sits_source_api_opendata.R b/R/sits_source_api_opendata.R new file mode 100644 index 000000000..3997e7fb0 --- /dev/null +++ b/R/sits_source_api_opendata.R @@ -0,0 +1,163 @@ +#' @keywords internal +#' @export +.source_item_get_date.opendata_cube <- function(source, + item, ..., + collection = NULL) { + item[[c("properties", "datetime")]] +} + +#' @keywords internal +#' @export +.source_item_get_hrefs.opendata_cube <- function(source, + item, ..., + collection = NULL) { + + href <- unname(purrr::map_chr(item[["assets"]], `[[`, "href")) + + # add gdal vsi in href urls + return(.stac_add_gdal_vsi(href)) +} + +#' @keywords internal +#' @export +.source_item_get_bands.opendata_cube <- function(source, + item, ..., + collection = NULL) { + names(item[["assets"]]) +} + +#' @keywords internal +#' @export +.source_item_get_resolutions.opendata_cube <- function(source, + item, ..., + collection = NULL) { + + res <- .source_bands_resolutions( + source = source, + collection = collection, + bands = .source_item_get_bands(source = source, + item = item) + ) + + unlist(res) +} + +#' @keywords internal +#' @export +.source_items_new.opendata_cube <- function(source, + collection, ..., + stac_query, + tiles = NULL) { + + # set caller to show in errors + .check_set_caller(".source_items_new.opendata_cube") + + # if specified, a filter per tile is added to the query + if (!is.null(tiles)) { + sep_tile <- .aws_tiles(tiles) + + stac_query <- + rstac::ext_query(q = stac_query, + "sentinel:utm_zone" %in% sep_tile$utm_zone, + "sentinel:latitude_band" %in% sep_tile$lat_band, + "sentinel:grid_square" %in% sep_tile$grid_square) + } + + # making the request + items_info <- rstac::post_request(q = stac_query, ...) + + # check if matched items + .check_that( + x = rstac::items_matched(items_info) > 0, + msg = "no items matched the query criteria." + ) + + # if more than 2 times items pagination are found the progress bar + # is displayed + pgr_fetch <- rstac::items_matched(items_info) > 2 * .config_rstac_limit() + + # fetching all the metadata + items_info <- rstac::items_fetch(items = items_info, progress = pgr_fetch) + + return(items_info) +} + +#' @keywords internal +#' @export +.source_items_tiles_group.opendata_cube <- function(source, + items, ..., + collection = NULL) { + + # store tile info in items object + items$features <- purrr::map(items$features, function(feature) { + feature$properties$tile <- paste0( + feature$properties[["sentinel:utm_zone"]], + feature$properties[["sentinel:latitude_band"]], + feature$properties[["sentinel:grid_square"]]) + + feature + }) + + rstac::items_group(items, field = c("properties", "tile")) +} + +#' @keywords internal +#' @export +.source_items_tile_get_crs.opendata_cube <- function(source, + tile_items, ..., + collection = NULL) { + + # format collection crs + crs <- .sits_proj_format_crs( + tile_items[["features"]][[1]][[c("properties", "proj:epsg")]] + ) + + return(crs) +} + +#' @keywords internal +#' @export +.source_items_tile_get_name.opendata_cube <- function(source, + tile_items, ..., + collection = NULL) { + + tile_items[["features"]][[1]][[c("properties", "tile")]] +} + +#' @keywords internal +#' @export +.source_items_tile_get_bbox.opendata_cube <- function(source, + tile_items, ..., + collection = NULL) { + + + href <- .source_item_get_hrefs(source = source, + item = tile_items[["features"]][[1]], ..., + collection = collection) + + # read the first image and obtain the size parameters + params <- .raster_params_file(href) + + bbox <- c(xmin = params[["xmin"]], ymin = params[["ymin"]], + xmax = params[["xmax"]], ymax = params[["ymax"]]) + + return(bbox) +} + +#' @keywords internal +#' @export +.source_items_tile_get_size.opendata_cube <- function(source, + tile_items, ..., + collection = NULL) { + + href <- .source_item_get_hrefs(source = source, + item = tile_items[["features"]][[1]], ..., + collection = collection) + + # read the first image and obtain the size parameters + params <- .raster_params_file(href) + + size <- c(nrows = params[["nrows"]], ncols = params[["ncols"]]) + + return(size) +} diff --git a/R/sits_stac.R b/R/sits_stac.R index 3e61feebf..87244a607 100644 --- a/R/sits_stac.R +++ b/R/sits_stac.R @@ -58,9 +58,9 @@ # verify the provided parameters if (!inherits(roi, "sf")) { - if (all(c("xmin", "ymin", "xmax", "ymax") %in% names(roi))) + if (all(c("lon_min", "lat_min", "lon_max", "lat_max") %in% names(roi))) roi_list[c("bbox", "intersects")] <- - list(roi[c("xmin", "ymin", "xmax", "ymax")], NULL) + list(roi[c("lon_min", "lat_min", "lon_max", "lat_max")], NULL) else if (typeof(roi) == "character") roi_list[c("bbox", "intersects")] <- list(NULL, roi) diff --git a/R/sits_view.R b/R/sits_view.R index b9d72dc62..de480afe2 100644 --- a/R/sits_view.R +++ b/R/sits_view.R @@ -18,19 +18,20 @@ #' #' @examples #' \donttest{ -#' data_dir <- system.file("extdata/raster/cbers", package = "sits") +#' data_dir <- system.file("extdata/raster/mod13q1", package = "sits") #' -#' cbers_022024 <- sits_cube( +#' modis_cube <- sits_cube( #' source = "LOCAL", -#' name = "cbers_022024", +#' name = "modis_sinop", #' origin = "BDC", -#' collection = "CB4_64-1", -#' resolution = 64, +#' collection = "MOD13Q1-6", +#' band = "NDVI", #' data_dir = data_dir, #' parse_info = c("X1", "X2", "tile", "band", "date") #' ) +#' #' # plot the data cube -#' sits_view(cbers_022024, red = "B15", green = "B16", blue = "B13", time = 1) +#' sits_view(modis_cube, red = "EVI", green = "NDVI", blue = "EVI", time = 1) #' } #' #' @export diff --git a/README.Rmd b/README.Rmd index e55c45d8e..3a98bce73 100644 --- a/README.Rmd +++ b/README.Rmd @@ -121,13 +121,13 @@ one month period, as shown below. This can be done in SITS by the `sits_regularize` which use the [https://github.com/appelmar/gdalcubes](gdalcubes) package. For details in gdalcubes, please see Reference [4]. ```{r, eval = FALSE, echo = TRUE} -gc_cube <- sits_regularize(cube = s2_cube, +gc_cube <- sits_regularize(cube = s2_cube, name = "T20LKP_2018_2019_1M", - dir_images = tempdir(), + output_dir = tempdir(), period = "P1M", agg_method = "median", - resampling = "bilinear", - cloud_mask = TRUE) + cloud_mask = TRUE, + multicores = 2) ``` ### Accessing time series in data cubes diff --git a/README.md b/README.md index 4c5eb1f46..6e503fa54 100644 --- a/README.md +++ b/README.md @@ -127,13 +127,13 @@ in SITS by the `sits_regularize` which use the in gdalcubes, please see Reference \[4\]. ``` r -gc_cube <- sits_regularize(cube = s2_cube, +gc_cube <- sits_regularize(cube = s2_cube, name = "T20LKP_2018_2019_1M", - dir_images = tempdir(), + output_dir = tempdir(), period = "P1M", agg_method = "median", - resampling = "bilinear", - cloud_mask = TRUE) + cloud_mask = TRUE, + multicores = 2) ``` ### Accessing time series in data cubes @@ -149,7 +149,7 @@ library(sits) #> To provide additional configurations, create an YAML file and inform its path to environment variable 'SITS_CONFIG_USER_FILE'. #> Using raster package: terra #> SITS - satellite image time series analysis. -#> Loaded sits v0.14.0. +#> Loaded sits v0.14.0-2. #> See ?sits for help, citation("sits") for use in publication. #> See demo(package = "sits") for examples. # create a cube from a local file @@ -175,7 +175,7 @@ points <- sits_get_data(raster_cube, file = csv_raster_file) # show the points points[1:3,] -#> # A tibble: 3 x 7 +#> # A tibble: 3 × 7 #> longitude latitude start_date end_date label cube time_series #> #> 1 -55.7 -11.8 2013-09-14 2014-08-29 Pasture sinop-2014 diff --git a/demo/00Index b/demo/00Index index 6313769f6..9d5a5f42a 100644 --- a/demo/00Index +++ b/demo/00Index @@ -1,6 +1,5 @@ access_SATVEG Access time series using the SATVEG service classify_cbers_bdc Classify a set of CBERS AWFI images in the Brazil Data Cube -classify_cbers_local Classify a set of CBERS AWFI images stored in a local directory classify_ts Classify a time series using SVM classify_raster_xgb Classify MODIS image using extreme gradient boosting classify_raster_svm Classify MODIS image using SVM diff --git a/demo/classify_cbers_local.R b/demo/classify_cbers_local.R deleted file mode 100644 index 95031d1ae..000000000 --- a/demo/classify_cbers_local.R +++ /dev/null @@ -1,99 +0,0 @@ -# This is a demonstration of classification of using -# local data (images organised by tiles) -# The input is a CBERS-4 data set covering an area in the Cerrado -# of the state of Bahia (Brazil) -# with two bands (NDVI and EVI) -library(sits) -if (!requireNamespace("sitsdata", quietly = TRUE)) { - if (!requireNamespace("devtools", quietly = TRUE)) { - install.packages("devtools") - } - devtools::install_github("e-sensing/sitsdata") -} -# load the sitsdata library -library(sitsdata) - -# define the local directory to load the images -local_dir <- system.file("extdata/CBERS", package = "sitsdata") - -# define the local CBERS data cube -cbers_cube <- sits_cube( - source = "LOCAL", - name = "cbers_022024", - origin = "BDC", - collection = "CB4_64-1", - data_dir = local_dir, - parse_info = c("X1", "X2", "X3", "X4", "tile", "date", "X5", "band") -) - -# load the samples -data("samples_cerrado_cbers") - -# set up the bands -bands <- c("NDVI", "EVI") - -# select the ndvi and evi bands -cbers_samples_2bands <- sits_select( - data = samples_cerrado_cbers, - bands = bands -) - -# train a random forest model -tcnn_model <- sits_train( - data = cbers_samples_2bands, - ml_method = sits_rfor() -) - -# classify the data (remember to set the appropriate memory size) -cbers_probs <- sits_classify( - data = cbers_cube, - ml_model = tcnn_model, - memsize = 1, - multicores = 3, - output_dir = tempdir(), - verbose = TRUE -) - -# label the resulting probs maps -cbers_label <- sits_label_classification( - cube = cbers_probs, - memsize = 12, - multicores = 2, - output_dir = tempdir() -) - -# smoothen the probabibilities with bayesian estimator -cbers_bayes <- sits_smooth( - cube = cbers_probs, - type = "bayes", - memsize = 12, - multicores = 2, - output_dir = tempdir() -) - -# label the resulting smoothed probs maps -cbers_label_bayes <- sits_label_classification( - cube = cbers_bayes, - memsize = 12, - multicores = 2, - output_dir = tempdir() -) - - - -# view the image (first and last instances) -sits_view(cbers_cube, red = "EVI", green = "NDVI", blue = "EVI", time = 1) -sits_view(cbers_cube, red = "EVI", green = "NDVI", blue = "EVI", time = 23) - -# plot the probabilities for each class -plot(cbers_probs) - -# labels are "Cerradao" "Cerrado" "Cropland" "Pasture" - -mylegend <- list("Cerradao" = "darkgreen", "Cerrado" = "palegreen1", -"Cropland" = "orange2", "Pasture" = "yellow") - -plot(cbers_label, legend = mylegend) - -plot(cbers_label, palette = "default") - diff --git a/inst/extdata/config.yml b/inst/extdata/config.yml index 8aeb3d877..0555ed38b 100644 --- a/inst/extdata/config.yml +++ b/inst/extdata/config.yml @@ -198,25 +198,25 @@ sources: offset_value : 0 resampling : "bilinear" resolutions : [30] - band_name : "BAND1" + band_name : "band1" B2 : <<: *bdc_oli_band1 - band_name : "BAND2" + band_name : "band2" B3 : <<: *bdc_oli_band1 - band_name : "BAND3" + band_name : "band3" B4 : <<: *bdc_oli_band1 - band_name : "BAND4" + band_name : "band4" B5 : <<: *bdc_oli_band1 - band_name : "BAND5" + band_name : "band5" B6 : <<: *bdc_oli_band1 - band_name : "BAND6" + band_name : "band6" B7 : <<: *bdc_oli_band1 - band_name : "BAND7" + band_name : "band7" CLOUD : &bdc_oli_cloud bit_mask : FALSE band_name : "Fmask4" @@ -310,37 +310,37 @@ sources: offset_value : 0 resampling : "bilinear" resolutions : [10] - band_name : "BAND1" + band_name : "band1" B02 : <<: *bdc_msi_band1 - band_name : "BAND2" + band_name : "band2" B03 : <<: *bdc_msi_band1 - band_name : "BAND3" + band_name : "band3" B04 : <<: *bdc_msi_band1 - band_name : "BAND4" + band_name : "band4" B05 : <<: *bdc_msi_band1 - band_name : "BAND5" + band_name : "band5" B06 : <<: *bdc_msi_band1 - band_name : "BAND6" + band_name : "band6" B07 : <<: *bdc_msi_band1 - band_name : "BAND7" + band_name : "band7" B08 : <<: *bdc_msi_band1 - band_name : "BAND8" + band_name : "band8" B8A : <<: *bdc_msi_band1 - band_name : "BAND8a" + band_name : "band8a" B11 : <<: *bdc_msi_band1 - band_name : "BAND11" + band_name : "band11" B12 : <<: *bdc_msi_band1 - band_name : "BAND12" + band_name : "band12" CLOUD : bit_mask : FALSE band_name : "Fmask4" @@ -431,7 +431,7 @@ sources: 11 : "snow or ice" interp_values: [0, 1, 2, 3, 8, 9, 10, 11] resampling : "near" - resolutions : [20, 60] + resolutions : [10] satellite : "SENTINEL-2" sensor : "MSI" collection_name: "S2-SEN2COR_10_16D_STK-1" @@ -569,7 +569,7 @@ sources: service : "STAC" url : "https://earth-search.aws.element84.com/v0/" collections : - SENTINEL-S2-L2A : + SENTINEL-S2-L2A : bands : B01 : &aws_msi_60m missing_value: -9999 @@ -651,6 +651,167 @@ sources: AWS_DEFAULT_REGION : "eu-central-1" AWS_S3_ENDPOINT : "s3.amazonaws.com" AWS_REQUEST_PAYER : "requester" + SENTINEL-S2-L2A-COGS : + bands : + B01 : &aws_cog_msi_60m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolutions : [60] + band_name : "B01" + B02 : &aws_cog_msi_10m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolutions : [10] + band_name : "B02" + B03 : + <<: *aws_cog_msi_10m + band_name : "B03" + B04 : + <<: *aws_cog_msi_10m + band_name : "B04" + B05 : &aws_cog_msi_20m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolutions : [20] + band_name : "B05" + B06 : + <<: *aws_cog_msi_20m + band_name : "B06" + B07 : + <<: *aws_cog_msi_20m + band_name : "B07" + B08 : + <<: *aws_cog_msi_10m + band_name : "B08" + B8A : + <<: *aws_cog_msi_20m + band_name : "B8A" + B09 : + <<: *aws_cog_msi_60m + band_name : "B09" + B11 : + <<: *aws_cog_msi_20m + band_name : "B11" + B12 : + <<: *aws_cog_msi_20m + band_name : "B12" + CLOUD : + bit_mask : FALSE + band_name : "SCL" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values: [0, 1, 2, 3, 8, 9, 10, 11] + resampling : "near" + resolutions : [20, 60] + satellite : "SENTINEL-2" + sensor : "MSI" + collection_name: "sentinel-s2-l2a-cogs" + OPENDATA : + s3_class : ["opendata_cube", "stac_cube", "raster_cube"] + service : "STAC" + url : "https://earth-search.aws.element84.com/v0/" + collections : + SENTINEL-S2-L2A-COGS : + bands : + B01 : &aws_cog_msi_60m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolutions : [60] + band_name : "B01" + B02 : &aws_cog_msi_10m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolutions : [10] + band_name : "B02" + B03 : + <<: *aws_cog_msi_10m + band_name : "B03" + B04 : + <<: *aws_cog_msi_10m + band_name : "B04" + B05 : &aws_cog_msi_20m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolutions : [20] + band_name : "B05" + B06 : + <<: *aws_cog_msi_20m + band_name : "B06" + B07 : + <<: *aws_cog_msi_20m + band_name : "B07" + B08 : + <<: *aws_cog_msi_10m + band_name : "B08" + B8A : + <<: *aws_cog_msi_20m + band_name : "B8A" + B09 : + <<: *aws_cog_msi_60m + band_name : "B09" + B11 : + <<: *aws_cog_msi_20m + band_name : "B11" + B12 : + <<: *aws_cog_msi_20m + band_name : "B12" + CLOUD : + bit_mask : FALSE + band_name : "SCL" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values: [0, 1, 2, 3, 8, 9, 10, 11] + resampling : "near" + resolutions : [20] + satellite : "SENTINEL-2" + sensor : "MSI" + collection_name: "sentinel-s2-l2a-cogs" DEAFRICA : s3_class : ["deafrica_cube", "stac_cube", "raster_cube"] service : "STAC" diff --git a/inst/extdata/gdalcubes/s2la_aws.json b/inst/extdata/gdalcubes/s2la_aws.json index 7cf2327a7..00562d11d 100644 --- a/inst/extdata/gdalcubes/s2la_aws.json +++ b/inst/extdata/gdalcubes/s2la_aws.json @@ -77,7 +77,7 @@ "scale" : 0.0001, "pattern" : ".+B12\\.jp2" }, - "SCL" : { + "CLOUD" : { "pattern" : ".+SCL\\.jp2" } } diff --git a/inst/extdata/gdalcubes/s2la_aws_cogs.json b/inst/extdata/gdalcubes/s2la_aws_cogs.json new file mode 100644 index 000000000..e72e8c21d --- /dev/null +++ b/inst/extdata/gdalcubes/s2la_aws_cogs.json @@ -0,0 +1,84 @@ +{ + "description" : "Image collection format for Sentinel 2 Level 2A Open Data in AWS", + "references" : "https://roda.sentinel-hub.com/sentinel-s2-l2a/readme.html", + "example" : "/vsicurl/sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/59/W/MP/2021/9/S2A_59WMP_20210926_0_L2A/B01.tif", + "tags" : ["Sentinel", "Copernicus", "ESA", "TOA"], + "pattern" : ".+.tif", + "images" : { + "pattern" : ".*sentinel-s2-l2a-cogs((?:/[A-Za-z0-9_]+){6})/.*" + }, + "datetime" : { + "pattern" : ".*S2[A|B](?:_[A-Za-z0-9]+){1}_([A-Za-z0-9]+).*", + "format" : "%Y%m%d" + }, + "bands" : { + "B01" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B01\\.tif" + }, + "B02" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B02\\.tif" + }, + "B03" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B03\\.tif" + }, + "B04" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B04\\.tif" + }, + "B05" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B05\\.tif" + }, + "B06" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B06\\.tif" + }, + "B07" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B07\\.tif" + }, + "B08" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B08\\.tif" + }, + "B8A" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B8A\\.tif" + }, + "B09" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B09\\.tif" + }, + "B10" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B10\\.tif" + }, + "B11" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B11\\.tif" + }, + "B12" : { + "nodata" : 0, + "scale" : 0.0001, + "pattern" : ".+B12\\.tif" + }, + "CLOUD" : { + "pattern" : ".+SCL\\.tif" + } + } +} diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-02-02.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-02-02.tif deleted file mode 100644 index 384564816..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-02-02.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-02-18.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-02-18.tif deleted file mode 100644 index 7b614de39..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-02-18.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-03-06.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-03-06.tif deleted file mode 100644 index 6006921a8..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-03-06.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-03-22.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-03-22.tif deleted file mode 100644 index 3eeb6ed0c..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-03-22.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-04-07.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-04-07.tif deleted file mode 100644 index ced97924d..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-04-07.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-04-23.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-04-23.tif deleted file mode 100644 index 08218227f..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-04-23.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-05-09.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-05-09.tif deleted file mode 100644 index cf594bac8..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-05-09.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-05-25.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-05-25.tif deleted file mode 100644 index ef7c3cd56..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-05-25.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-06-10.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-06-10.tif deleted file mode 100644 index 87d121dd7..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-06-10.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-06-26.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-06-26.tif deleted file mode 100644 index bcba44eeb..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-06-26.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-07-12.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-07-12.tif deleted file mode 100644 index c41fd7921..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-07-12.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-07-28.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-07-28.tif deleted file mode 100644 index 9a0d17fd7..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-07-28.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-08-13.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-08-13.tif deleted file mode 100644 index 660456cf3..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-08-13.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-08-29.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-08-29.tif deleted file mode 100644 index 95b1fe48c..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B13_2018-08-29.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-02-02.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-02-02.tif deleted file mode 100644 index 770b67355..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-02-02.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-02-18.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-02-18.tif deleted file mode 100644 index 39e8f1ce4..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-02-18.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-03-06.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-03-06.tif deleted file mode 100644 index fbc0e3604..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-03-06.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-03-22.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-03-22.tif deleted file mode 100644 index 6277d40cb..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-03-22.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-04-07.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-04-07.tif deleted file mode 100644 index 55bd2db3b..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-04-07.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-04-23.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-04-23.tif deleted file mode 100644 index 261578406..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-04-23.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-05-09.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-05-09.tif deleted file mode 100644 index 610831507..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-05-09.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-05-25.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-05-25.tif deleted file mode 100644 index c8372f2a5..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-05-25.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-06-10.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-06-10.tif deleted file mode 100644 index 01f7e2471..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-06-10.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-06-26.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-06-26.tif deleted file mode 100644 index c482ecacd..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-06-26.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-07-12.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-07-12.tif deleted file mode 100644 index 9ea71ea8b..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-07-12.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-07-28.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-07-28.tif deleted file mode 100644 index 3b4bbea15..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-07-28.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-08-13.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-08-13.tif deleted file mode 100644 index 046731ca4..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-08-13.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-08-29.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-08-29.tif deleted file mode 100644 index e0ae4fca4..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B14_2018-08-29.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-02-02.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-02-02.tif deleted file mode 100644 index db2b111b4..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-02-02.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-02-18.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-02-18.tif deleted file mode 100644 index 37281a1c8..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-02-18.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-03-06.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-03-06.tif deleted file mode 100644 index dde94ba39..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-03-06.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-03-22.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-03-22.tif deleted file mode 100644 index f6ff0593e..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-03-22.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-04-07.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-04-07.tif deleted file mode 100644 index f71279d5e..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-04-07.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-04-23.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-04-23.tif deleted file mode 100644 index 99dff130c..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-04-23.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-05-09.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-05-09.tif deleted file mode 100644 index bb479dc82..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-05-09.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-05-25.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-05-25.tif deleted file mode 100644 index 4c44a6170..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-05-25.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-06-10.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-06-10.tif deleted file mode 100644 index ed799d45c..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-06-10.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-06-26.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-06-26.tif deleted file mode 100644 index c5e8471f0..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-06-26.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-07-12.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-07-12.tif deleted file mode 100644 index f4e89c534..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-07-12.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-07-28.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-07-28.tif deleted file mode 100644 index 109f4a0b2..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-07-28.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-08-13.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-08-13.tif deleted file mode 100644 index 540b984a2..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-08-13.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-08-29.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-08-29.tif deleted file mode 100644 index 4c78f80cd..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B15_2018-08-29.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-02-02.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-02-02.tif deleted file mode 100644 index d839fdeff..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-02-02.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-02-18.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-02-18.tif deleted file mode 100644 index f3b847e63..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-02-18.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-03-06.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-03-06.tif deleted file mode 100644 index 92a627837..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-03-06.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-03-22.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-03-22.tif deleted file mode 100644 index eb45df604..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-03-22.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-04-07.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-04-07.tif deleted file mode 100644 index c6868acae..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-04-07.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-04-23.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-04-23.tif deleted file mode 100644 index 74549f57d..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-04-23.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-05-09.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-05-09.tif deleted file mode 100644 index 8811dd008..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-05-09.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-05-25.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-05-25.tif deleted file mode 100644 index fc1400650..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-05-25.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-06-10.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-06-10.tif deleted file mode 100644 index 07702b938..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-06-10.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-06-26.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-06-26.tif deleted file mode 100644 index 31537f991..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-06-26.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-07-12.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-07-12.tif deleted file mode 100644 index 6e8eb4dc8..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-07-12.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-07-28.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-07-28.tif deleted file mode 100644 index 5be091fbb..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-07-28.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-08-13.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-08-13.tif deleted file mode 100644 index 693ba98e8..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-08-13.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-08-29.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-08-29.tif deleted file mode 100644 index da853c791..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_B16_2018-08-29.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-02-02.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-02-02.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-02-02.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-02-18.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-02-18.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-02-18.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-03-06.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-03-06.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-03-06.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-03-22.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-03-22.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-03-22.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-04-07.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-04-07.tif deleted file mode 100644 index 2464e1aa0..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-04-07.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-04-23.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-04-23.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-04-23.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-05-09.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-05-09.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-05-09.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-05-25.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-05-25.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-05-25.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-06-10.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-06-10.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-06-10.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-06-26.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-06-26.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-06-26.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-07-12.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-07-12.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-07-12.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-07-28.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-07-28.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-07-28.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-08-13.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-08-13.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-08-13.tif and /dev/null differ diff --git a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-08-29.tif b/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-08-29.tif deleted file mode 100644 index 9ccab5b84..000000000 Binary files a/inst/extdata/raster/cbers/CBERS-4_AWFI_022024_CMASK_2018-08-29.tif and /dev/null differ diff --git a/man/dot-sits_gc_cloud_mask.Rd b/man/dot-gc_cloud_mask.Rd similarity index 84% rename from man/dot-sits_gc_cloud_mask.Rd rename to man/dot-gc_cloud_mask.Rd index d4a344d9b..bcf8d11fc 100644 --- a/man/dot-sits_gc_cloud_mask.Rd +++ b/man/dot-gc_cloud_mask.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/sits_gdalcubes.R -\name{.sits_gc_cloud_mask} -\alias{.sits_gc_cloud_mask} +\name{.gc_cloud_mask} +\alias{.gc_cloud_mask} \title{Create an object image_mask with information about mask band} \usage{ -.sits_gc_cloud_mask(tile) +.gc_cloud_mask(tile) } \arguments{ \item{tile}{Data cube tile from where data is to be retrieved.} diff --git a/man/dot-sits_gc_cube.Rd b/man/dot-gc_create_cube_view.Rd similarity index 67% rename from man/dot-sits_gc_cube.Rd rename to man/dot-gc_create_cube_view.Rd index 66cbc7e5a..1718bb5df 100644 --- a/man/dot-sits_gc_cube.Rd +++ b/man/dot-gc_create_cube_view.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/sits_gdalcubes.R -\name{.sits_gc_cube} -\alias{.sits_gc_cube} +\name{.gc_create_cube_view} +\alias{.gc_create_cube_view} \title{Create a cube_view object} \usage{ -.sits_gc_cube(tile, period, roi, toi, agg_method, resampling) +.gc_create_cube_view(tile, period, res, roi, toi, agg_method) } \arguments{ \item{tile}{A data cube tile} @@ -13,6 +13,9 @@ is desired to apply in the cube, must be provided based on ISO8601, where 1 number and a unit are provided, for example "P16D".} +\item{res}{A \code{numeric} with spatial resolution of the image that +will be aggregated.} + \item{roi}{A region of interest.} \item{toi}{A timeline of intersection} @@ -20,11 +23,6 @@ number and a unit are provided, for example "P16D".} \item{agg_method}{A \code{character} with the method that will be applied in the aggregation, the following are available: "min", "max", "mean", "median" or "first".} - -\item{resampling}{A \code{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).} } \value{ a \code{cube_view} object from gdalcubes. diff --git a/man/dot-sits_gc_database.Rd b/man/dot-gc_create_database.Rd similarity index 84% rename from man/dot-sits_gc_database.Rd rename to man/dot-gc_create_database.Rd index e1c4c40b2..d690160ac 100644 --- a/man/dot-sits_gc_database.Rd +++ b/man/dot-gc_create_database.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/sits_gdalcubes.R -\name{.sits_gc_database} -\alias{.sits_gc_database} +\name{.gc_create_database} +\alias{.gc_create_database} \title{Create an image_collection object} \usage{ -.sits_gc_database(cube, path_db) +.gc_create_database(cube, path_db) } \arguments{ \item{cube}{Data cube from where data is to be retrieved.} diff --git a/man/dot-sits_gc_date.Rd b/man/dot-gc_get_date.Rd similarity index 85% rename from man/dot-sits_gc_date.Rd rename to man/dot-gc_get_date.Rd index 1617560cb..a59442b19 100644 --- a/man/dot-sits_gc_date.Rd +++ b/man/dot-gc_get_date.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/sits_gdalcubes.R -\name{.sits_gc_date} -\alias{.sits_gc_date} +\name{.gc_get_date} +\alias{.gc_get_date} \title{Extracted date from aggregated cubes} \usage{ -.sits_gc_date(dir_images) +.gc_get_date(dir_images) } \arguments{ \item{dir_images}{A \code{character} corresponds to the path on which the diff --git a/man/dot-sits_gc_compose.Rd b/man/dot-gc_new_cube.Rd similarity index 81% rename from man/dot-sits_gc_compose.Rd rename to man/dot-gc_new_cube.Rd index e708e0e4c..20a209c5c 100644 --- a/man/dot-sits_gc_compose.Rd +++ b/man/dot-gc_new_cube.Rd @@ -1,16 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/sits_gdalcubes.R -\name{.sits_gc_compose} -\alias{.sits_gc_compose} +\name{.gc_new_cube} +\alias{.gc_new_cube} \title{Save the images based on an aggregation method.} \usage{ -.sits_gc_compose( +.gc_new_cube( tile, name, cv, img_col, - db_file, - dir_images, + path_db, + output_dir, cloud_mask, ..., version = "v1" @@ -26,9 +26,9 @@ \item{img_col}{A \code{object} 'image_collection' containing information about the images metadata.} -\item{db_file}{Database to be created by gdalcubes} +\item{path_db}{Database to be created by gdalcubes} -\item{dir_images}{Directory where the aggregated images will be written.} +\item{output_dir}{Directory where the aggregated images will be written.} \item{cloud_mask}{A \code{logical} corresponds to the use of the cloud band for aggregation.} diff --git a/man/dot-sits_gc_brick.Rd b/man/dot-gc_raster_cube.Rd similarity index 87% rename from man/dot-sits_gc_brick.Rd rename to man/dot-gc_raster_cube.Rd index 001ae4309..f590c4524 100644 --- a/man/dot-sits_gc_brick.Rd +++ b/man/dot-gc_raster_cube.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/sits_gdalcubes.R -\name{.sits_gc_brick} -\alias{.sits_gc_brick} +\name{.gc_raster_cube} +\alias{.gc_raster_cube} \title{Create a raster_cube object} \usage{ -.sits_gc_brick(cube, img_col, cv, cloud_mask) +.gc_raster_cube(cube, img_col, cv, cloud_mask) } \arguments{ \item{cube}{Data cube from where data is to be retrieved.} diff --git a/man/dot-gc_update_metadata.Rd b/man/dot-gc_update_metadata.Rd new file mode 100644 index 000000000..0cbec5cdd --- /dev/null +++ b/man/dot-gc_update_metadata.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sits_gdalcubes.R +\name{.gc_update_metadata} +\alias{.gc_update_metadata} +\title{Update metadata from sits cube using gdalcubes metadata} +\usage{ +.gc_update_metadata(cube, cube_view) +} +\arguments{ +\item{cube}{Data cube from where data is to be retrieved.} + +\item{cv}{A \code{object} 'cube_view' with values from cube. +for aggregation.} +} +\value{ +a \code{sits_cube} object with updated metadata. +} +\description{ +Update metadata from sits cube using gdalcubes metadata +} +\keyword{internal} diff --git a/man/dot-sits_get_data_from_wtss.Rd b/man/dot-sits_get_data_from_wtss.Rd index cdaf6dc57..262037a12 100644 --- a/man/dot-sits_get_data_from_wtss.Rd +++ b/man/dot-sits_get_data_from_wtss.Rd @@ -11,7 +11,8 @@ start_date = NULL, end_date = NULL, bands = NULL, - label = "NoClass" + label = "NoClass", + impute_fn = sits_impute_linear() ) } \arguments{ diff --git a/man/figures/README-unnamed-chunk-11-1.png b/man/figures/README-unnamed-chunk-11-1.png index f524f9502..adadba472 100644 Binary files a/man/figures/README-unnamed-chunk-11-1.png and b/man/figures/README-unnamed-chunk-11-1.png differ diff --git a/man/gdalcubes_format_col.Rd b/man/gdalcubes_format_col.Rd new file mode 100644 index 000000000..e4cb38223 --- /dev/null +++ b/man/gdalcubes_format_col.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sits_gdalcubes.R +\name{gdalcubes_format_col} +\alias{gdalcubes_format_col} +\alias{.gc_format_col} +\title{Internal function to handle with different file collection formats + for each provider.} +\usage{ +.gc_format_col(source, ...) +} +\arguments{ +\item{source}{A \code{character} value referring to a valid data source.} + +\item{...}{Additional parameters.} +} +\value{ +A \code{character} path with format collection. +} +\description{ +Generic function with the goal that each source implements its own way of +localizing the collection format file. +} +\keyword{internal} diff --git a/man/sits_classify.Rd b/man/sits_classify.Rd index e3cb52318..32ee4a26a 100644 --- a/man/sits_classify.Rd +++ b/man/sits_classify.Rd @@ -91,7 +91,7 @@ SITS supports the following models: 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", "lon_min", "lon_max") + named lat/long values ("lon_min", "lat_min", "lon_max", "lat_max") The "filter_fn" parameter specifies a smoothing filter to be applied to time series for reducing noise. Currently, options include diff --git a/man/sits_configuration.Rd b/man/sits_configuration.Rd index 2b7e62acc..104ce2c47 100644 --- a/man/sits_configuration.Rd +++ b/man/sits_configuration.Rd @@ -4,6 +4,7 @@ \alias{sits_configuration} \alias{sits_config} \alias{sits_config_show} +\alias{sits_list_collections} \title{sits configuration} \usage{ sits_config( @@ -15,6 +16,8 @@ sits_config( ) sits_config_show(source = NULL, collection = NULL, palette = NULL) + +sits_list_collections(source = NULL) } \arguments{ \item{processing_bloat}{A \code{numeric} value to estimate @@ -49,6 +52,9 @@ configuration options. \code{sits_config_show()} returns a \code{list} containing the respective configuration printed in the console. + +\code{sits_list_collections()} prints the collections available in +each cloud service supported by sits. } \description{ These functions load and show sits configurations. @@ -61,8 +67,12 @@ obtained by overriding the options by the values provided in \code{sits_config_show()} prints the current sits configuration options. To show specific configuration options for -a source, a collection, or a palette, user can inform the corresponding +a source, a collection, or a palette, users can inform the corresponding keys to \code{source}, \code{collection}, and \code{palette} parameters. + +\code{sits_list_collections()} prints the collections available +in each cloud service supported by sits. Users can select to get information +only for a single service by using the \code{source} parameter. } \details{ Users can provide additional configuration files, by specifying the diff --git a/man/sits_cube.Rd b/man/sits_cube.Rd index 3283236aa..99eb7a93f 100644 --- a/man/sits_cube.Rd +++ b/man/sits_cube.Rd @@ -6,6 +6,7 @@ \alias{sits_cube.bdc_cube} \alias{sits_cube.deafrica_cube} \alias{sits_cube.aws_cube} +\alias{sits_cube.opendata_cube} \alias{sits_cube.usgs_cube} \alias{sits_cube.local_cube} \alias{sits_cube.probs_cube} @@ -23,7 +24,7 @@ sits_cube(source, ...) collection, bands = NULL, tiles = NULL, - bbox = NULL, + roi = NULL, start_date = NULL, end_date = NULL ) @@ -36,7 +37,7 @@ sits_cube(source, ...) collection = "S2_L2A", bands = NULL, tiles = NULL, - bbox = NULL, + roi = NULL, start_date = NULL, end_date = NULL ) @@ -49,12 +50,25 @@ sits_cube(source, ...) collection = "sentinel-s2-l2a", tiles = NULL, bands = NULL, - bbox = NULL, + roi = NULL, s2_resolution = 20, start_date = NULL, end_date = NULL ) +\method{sits_cube}{opendata_cube}( + source = "OPENDATA", + ..., + name = "opendata_cube", + url = NULL, + collection = "sentinel-s2-l2a-cogs", + tiles = NULL, + bands = NULL, + roi = NULL, + start_date = NULL, + end_date = NULL +) + \method{sits_cube}{usgs_cube}( source = "USGS", ..., @@ -63,7 +77,7 @@ sits_cube(source, ...) collection = "landsat-c2l2-sr", tiles = NULL, bands = NULL, - bbox = NULL, + roi = NULL, start_date = NULL, end_date = NULL ) @@ -113,7 +127,7 @@ sits_cube(source, ...) \item{tiles}{Tiles from the collection to be included in the data cube.} -\item{bbox}{Area of interest (see details below).} +\item{roi}{Region of interest (see details below).} \item{start_date}{Initial date for the cube (optional).} @@ -184,8 +198,8 @@ in two ways: (a) a region of interest(`bbox`) in WGS 84 coordinates; } } \details{ -The \code{bbox} parameter allows a selection of an area of interest. -Either using a named \code{vector} ("xmin", "ymin", "xmax", "ymax") with +The \code{roi} parameter allows a selection of an area of interest. +Either using a named \code{vector} ("lon_min", "lat_min", "lon_max", "lat_max") with values in WGS 84, a \code{sfc} or \code{sf} object from sf package, or a GeoJSON geometry (RFC 7946). Note that this parameter does not crop a region, but only selects the images that intersect with it. @@ -299,14 +313,14 @@ s2_cube <- sits_cube(source = "AWS", s2_resolution = 20 ) -# --- Create a cube based on a stack of CBERS data -data_dir <- system.file("extdata/raster/cbers", package = "sits") +# --- Create a cube based on a local MODIS data +data_dir <- system.file("extdata/raster/mod13q1", package = "sits") -cbers_cube <- sits_cube( +modis_cube <- sits_cube( source = "LOCAL", - name = "022024", + name = "modis_sinop", origin = "BDC", - collection = "CB4_64-1", + collection = "MOD13Q1-6", data_dir = data_dir, delim = "_", parse_info = c("X1", "X2", "tile", "band", "date") diff --git a/man/sits_cube_copy.Rd b/man/sits_cube_copy.Rd index b1cfcdcc3..46827452a 100644 --- a/man/sits_cube_copy.Rd +++ b/man/sits_cube_copy.Rd @@ -29,20 +29,20 @@ a box in lat-long coordinates ("lon_min", "lon_max", "lat_min", "lat_max"). } \examples{ \donttest{ -data_dir <- system.file("extdata/raster/cbers", package = "sits") +data_dir <- system.file("extdata/raster/mod13q1", package = "sits") -cbers_022024 <- sits_cube( +modis_cube <- sits_cube( source = "LOCAL", - name = "cbers_022024", + name = "modis_sinop", origin = "BDC", - collection = "CB4_64-1", + collection = "MOD13Q1-6", band = "NDVI", data_dir = data_dir, parse_info = c("X1", "X2", "tile", "band", "date") ) -cbers_022024_copy <- sits_cube_copy(cbers_022024, - name = "cb_022024_cp", +modis_cube_copy <- sits_cube_copy(modis_cube, + name = "modis_sinop_cp", dest_dir = tempdir() ) } diff --git a/man/sits_get_data.Rd b/man/sits_get_data.Rd index 235af1b6a..4801e31f6 100644 --- a/man/sits_get_data.Rd +++ b/man/sits_get_data.Rd @@ -24,7 +24,8 @@ sits_get_data(cube, file = NULL, ..., multicores = 1) start_date = NULL, end_date = NULL, bands = NULL, - label = "NoClass" + label = "NoClass", + impute_fn = sits_impute_linear() ) \method{sits_get_data}{satveg_cube}( @@ -38,7 +39,7 @@ sits_get_data(cube, file = NULL, ..., multicores = 1) label = "NoClass" ) -\method{sits_get_data}{csv_wtss_cube}(cube, file, ..., bands = NULL) +\method{sits_get_data}{csv_wtss_cube}(cube, file, ..., bands = NULL, impute_fn = sits_impute_linear()) \method{sits_get_data}{csv_satveg_cube}(cube, file, ...) @@ -50,6 +51,7 @@ sits_get_data(cube, file = NULL, ..., multicores = 1) end_date = NULL, bands = NULL, label = "NoClass", + impute_fn = sits_impute_linear(), shp_attr = NULL, .n_shp_pol = 30 ) @@ -125,14 +127,14 @@ in "YYYY-MM-DD" format (optional).} \item{label}{Label to be assigned to the time series (optional).} +\item{impute_fn}{Imputation function for NA values.} + \item{shp_attr}{Attribute in the shapefile to be used as a polygon label.} \item{.n_shp_pol}{Number of samples per polygon to be read (for POLYGON or MULTIPOLYGON shapefile).} -\item{impute_fn}{Imputation function for NA values.} - \item{.n_pts_csv}{Number of points from CSV file to be retrieved.} } \value{ diff --git a/man/sits_regularize.Rd b/man/sits_regularize.Rd index a0185d33e..a0d836c0d 100644 --- a/man/sits_regularize.Rd +++ b/man/sits_regularize.Rd @@ -7,42 +7,54 @@ sits_regularize( cube, name, - dir_images, + output_dir, period = NULL, + res = NULL, roi = NULL, agg_method = NULL, - resampling = "bilinear", - cloud_mask = TRUE + cloud_mask = TRUE, + multicores = 1 ) } \arguments{ -\item{cube}{A cube whose spacing of observation times is -not constant and will be regularized by the -"gdalcubes" packges} +\item{cube}{A \code{sits_cube} object whose spacing of observation +times is not constant and will be regularized by the \code{gdalcubes} +package.} -\item{name}{Name of the output data cube} +\item{name}{A \code{character} with name of the output data cube} -\item{dir_images}{Directory where the regularized images will be -written by \code{gdalcubes}.} +\item{output_dir}{A \code{character} with a directory where the regularized +images will be written by \code{gdalcubes}.} -\item{period}{ISO8601 time period for regular data cubes -produced by \code{gdalcubes}, -with number and unit, e.g., "P16D" for 16 days. -Use "D", "M" and "Y" for days, month and year..} +\item{period}{A \code{character} with ISO8601 time period for regular +data cubes produced by \code{gdalcubes}, with number and unit, e.g., "P16D" +for 16 days. Use "D", "M" and "Y" for days, month and year.} -\item{roi}{A region of interest (see above)} +\item{res}{A \code{numeric} with spatial resolution of the image that +will be aggregated.} -\item{agg_method}{Method that will be applied by \code{gdalcubes} -for aggregation. Options: "min", "max", "mean", -"median" and "first".} +\item{roi}{A named \code{numeric} vector with a region of interest. +See above} -\item{resampling}{Method to be used by \code{gdalcubes} -for resampling in mosaic operation. -Options: "near", "bilinear", "bicubic" -or others supported by gdalwarp -(see https://gdal.org/programs/gdalwarp.html).} +\item{agg_method}{A \code{character} with method that will be applied by +\code{gdalcubes} for aggregation. +Options: \code{min}, \code{max}, \code{mean}, \code{median} and +\code{first}.} -\item{cloud_mask}{Use cloud band for aggregation by \code{gdalcubes}?} +\item{cloud_mask}{A \code{logical} to use cloud band for aggregation by +\code{gdalcubes}. Default is \code{TRUE}.} + +\item{multicores}{A \code{numeric} with the number of cores will be used in +the regularize. By default is used 1 core.} + +\item{resampling}{A \code{character} with method to be used by +\code{gdalcubes} for resampling in mosaic operation. +Options: \code{near}, \code{bilinear}, \code{bicubic} or others supported by +gdalwarp (see https://gdal.org/programs/gdalwarp.html). +By default is bilinear.} +} +\value{ +A \code{sits_cube} object with aggregated images. } \description{ Creates cubes with regular time intervals diff --git a/man/sits_view.Rd b/man/sits_view.Rd index 2ac91fe10..3f98749c6 100644 --- a/man/sits_view.Rd +++ b/man/sits_view.Rd @@ -39,19 +39,20 @@ Uses mapview to visualize raster cube and classified images } \examples{ \donttest{ -data_dir <- system.file("extdata/raster/cbers", package = "sits") +data_dir <- system.file("extdata/raster/mod13q1", package = "sits") -cbers_022024 <- sits_cube( +modis_cube <- sits_cube( source = "LOCAL", - name = "cbers_022024", + name = "modis_sinop", origin = "BDC", - collection = "CB4_64-1", - resolution = 64, + collection = "MOD13Q1-6", + band = "NDVI", data_dir = data_dir, parse_info = c("X1", "X2", "tile", "band", "date") ) + # plot the data cube -sits_view(cbers_022024, red = "B15", green = "B16", blue = "B13", time = 1) +sits_view(modis_cube, red = "EVI", green = "NDVI", blue = "EVI", time = 1) } } diff --git a/man/source_bands.Rd b/man/source_bands.Rd index 388c62368..bb158570d 100644 --- a/man/source_bands.Rd +++ b/man/source_bands.Rd @@ -6,6 +6,7 @@ \alias{.source_bands_reap} \alias{.source_bands_band_name} \alias{.source_bands_resolutions} +\alias{.source_bands_resampling} \alias{.source_bands_to_sits} \alias{.source_bands_to_source} \alias{.source_cloud} @@ -38,6 +39,15 @@ add_cloud = TRUE ) +.source_bands_resampling( + source, + collection, + ..., + bands = NULL, + fn_filter = NULL, + add_cloud = TRUE +) + .source_bands_to_sits(source, collection, bands) .source_bands_to_source(source, collection, bands) @@ -89,6 +99,9 @@ found, \code{default} value is returned. containing \code{numeric} vectors with all supported resolutions of a band. +\code{.source_bands_resampling()} returns a \code{character} +vectors with the desired resampling method that should be used in the band. + \code{.source_bands_to_sits()} returns a \code{character} vector with all converted bands name. @@ -122,6 +135,9 @@ attribute of all bands filtered by its parameters. \code{.source_bands_resolutions()} returns the \code{resolutions} attribute of all bands filtered by its parameters. +\code{.source_bands_resampling()} returns the +\code{resampling} attribute of all bands filtered by its parameters. + \code{.source_bands_to_sits()} converts any bands to its sits name indicated in band entry. diff --git a/tests/testthat/test-accuracy.R b/tests/testthat/test-accuracy.R index 39c42ce40..4fc336f73 100644 --- a/tests/testthat/test-accuracy.R +++ b/tests/testthat/test-accuracy.R @@ -83,5 +83,7 @@ test_that("Accuracy areas", { expect_true(as.numeric(as$area_pixels["Forest"]) > as$area_pixels["Pasture"]) - expect_true(as.numeric(as$accuracy$overall) > 0.75) + expect_equal(as.numeric(as$accuracy$overall), + expected = 0.75, + tolerance = 0.5) }) diff --git a/tests/testthat/test-config.R b/tests/testthat/test-config.R index 9da1ec681..983dad45e 100644 --- a/tests/testthat/test-config.R +++ b/tests/testthat/test-config.R @@ -41,7 +41,7 @@ test_that("User functions", { expect_equal( .sources(), - c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", + c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", "OPENDATA", "DEAFRICA", "LOCAL") ) @@ -84,7 +84,7 @@ test_that("User functions", { expect_equal( .sources(), - c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", + c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", "OPENDATA", "DEAFRICA", "LOCAL") ) @@ -149,7 +149,7 @@ test_that("User functions", { expect_equal( .sources(), - c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", + c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", "OPENDATA", "DEAFRICA", "LOCAL") ) @@ -164,7 +164,7 @@ test_that("User functions", { expect_true( any(grepl( - "- CLASSIFIED, PROBS, BDC, WTSS, SATVEG, AWS, DEAFRICA, LOCAL", + "- CLASSIFIED, PROBS, BDC, WTSS, SATVEG, AWS, OPENDATA, DEAFRICA, LOCAL", config_txt )) ) @@ -233,7 +233,7 @@ test_that("User functions", { expect_equal( .sources(), - c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", + c("CLASSIFIED", "PROBS", "BDC", "WTSS", "SATVEG", "AWS", "OPENDATA", "DEAFRICA", "LOCAL", "TEST") ) diff --git a/tests/testthat/test-cube.R b/tests/testthat/test-cube.R index 04f065747..4a05c1151 100644 --- a/tests/testthat/test-cube.R +++ b/tests/testthat/test-cube.R @@ -45,16 +45,16 @@ test_that("Reading a raster cube", { }) test_that("Creating a raster stack cube and selecting bands", { - # Create a raster cube based on CBERS data - data_dir <- system.file("extdata/raster/cbers", package = "sits") + # Create a raster cube based on MODIS data + data_dir <- system.file("extdata/raster/mod13q1", package = "sits") # create a raster cube file based on the information about the files - cbers_cube <- tryCatch({ + modis_cube <- tryCatch({ sits_cube( source = "LOCAL", name = "022024", origin = "BDC", - collection = "CB4_64-1", + collection = "MOD13Q1-6", data_dir = data_dir, delim = "_", parse_info = c("X1", "X2", "tile", "band", "date") @@ -64,19 +64,19 @@ test_that("Creating a raster stack cube and selecting bands", { return(NULL) }) - testthat::skip_if(purrr::is_null(cbers_cube), + testthat::skip_if(purrr::is_null(modis_cube), message = "LOCAL cube not found") - expect_true(all(sits_bands(cbers_cube) %in% - c("B13", "B14", "B15", "B16", "CLOUD"))) - rast <- .raster_open_rast(cbers_cube$file_info[[1]]$path[[1]]) - expect_true(.raster_nrows(rast) == cbers_cube$nrows[[1]]) - timeline <- sits_timeline(cbers_cube) - expect_true(timeline[1] == "2018-02-02") + expect_true(all(sits_bands(modis_cube) %in% + c("EVI", "NDVI"))) + rast <- sits:::.raster_open_rast(modis_cube$file_info[[1]]$path[[1]]) + expect_true(sits:::.raster_nrows(rast) == modis_cube$nrows[[1]]) + timeline <- sits_timeline(modis_cube) + expect_true(timeline[1] == "2013-09-14") - cbers_cube_b13 <- sits_select(cbers_cube, bands = "B13") - expect_true(all(sits_bands(cbers_cube_b13) == c("B13"))) + modis_cube_evi <- sits_select(modis_cube, bands = "EVI") + expect_true(all(sits_bands(modis_cube_evi) == c("EVI"))) }) test_that("Creating cubes from BDC", { @@ -225,9 +225,9 @@ test_that("Merging cubes", { sits_cube( source = "LOCAL", name = "sinop-2014", - satellite = "TERRA", - sensor = "MODIS", + origin = "BDC", bands = "NDVI", + collection = "MOD13Q1-6", data_dir = data_dir, delim = "_", parse_info = c("X1", "X2", "tile", "band", "date") @@ -267,7 +267,7 @@ test_that("Merging cubes", { expect_true(cube_merge$xmax == evi_cube$xmax) }) -test_that("Creating cubes from AWS and regularizing them", { +test_that("Creating cubes from AWS", { testthat::skip_on_cran() @@ -312,6 +312,21 @@ test_that("Creating cubes from AWS and regularizing them", { expect_equal(s2_cube$ncols[[1]], sits:::.raster_ncols(r)) expect_equal(s2_cube$xmax[[1]], sits:::.raster_xmax(r)) expect_equal(s2_cube$xmin[[1]], sits:::.raster_xmin(r)) +}) + +test_that("Creating cubes from AWS OPen Data and regularizing them", { + + + testthat::expect_warning({ + s2_cube <- sits_cube(source = "OPENDATA", + name = "T20LKP_2018_2019", + collection = "sentinel-s2-l2a-cogs", + tiles = "20LKP", + bands = c("B08", "SCL"), + start_date = "2018-07-30", + end_date = "2018-08-30" + ) + }) dir_images <- paste0(tempdir(), "/images/") if (!dir.exists(dir_images)) @@ -320,24 +335,24 @@ test_that("Creating cubes from AWS and regularizing them", { gc_cube <- sits_regularize( cube = s2_cube, name = "T20LKP_2018_2019_P5D", - dir_images = dir_images, + output_dir = dir_images, + res = 250, roi = c("xmin" = 234872.7, "ymin" = 8847983.0, "xmax" = 239532.6, "ymax" = 8852017.0), period = "P15D", agg_method = "median", - resampling = "bilinear" - ) + multicores = 2) - expect_equal(s2_cube$nrows, gc_cube$nrows) - expect_equal(s2_cube$ncols, gc_cube$ncols) - expect_equal(s2_cube$xmax, gc_cube$xmax) - expect_equal(s2_cube$xmin, gc_cube$xmin) + expect_equal(gc_cube$nrows, 17) + expect_equal(gc_cube$ncols, 19) + expect_equal(gc_cube$xmax, 239577.7, tolerance = 1e-1) + expect_equal(gc_cube$xmin, 234827.7, tolerance = 1e-1) file_info2 <- gc_cube$file_info[[1]] - expect_equal(nrow(file_info2), 4) + expect_equal(nrow(file_info2), 2) }) test_that("Creating cubes from classified images", { @@ -381,14 +396,14 @@ test_that("Creating cubes from classified images", { }) test_that("Cube copy", { - data_dir <- system.file("extdata/raster/cbers", package = "sits") + data_dir <- system.file("extdata/raster/mod13q1", package = "sits") - cbers_022024 <- tryCatch({ + modis_cube <- tryCatch({ sits_cube( source = "LOCAL", - name = "cbers_022024", + name = "modis_sinop", origin = "BDC", - collection = "CB4_64-1", + collection = "MOD13Q1-6", data_dir = data_dir, parse_info = c("X1", "X2", "tile", "band", "date") ) @@ -397,56 +412,24 @@ test_that("Cube copy", { return(NULL) }) - testthat::skip_if(purrr::is_null(cbers_022024), + testthat::skip_if(purrr::is_null(modis_cube), message = "LOCAL cube not found") - bbox <- sits_bbox(cbers_022024) + bbox <- sits_bbox(modis_cube) x_size <- bbox["xmax"] - bbox["xmin"] bbox["xmax"] <- bbox["xmin"] + x_size / 2 - cbers_022024_copy <- sits_cube_copy(cbers_022024, - name = "cb_022024_cp", + modis_cube_copy <- suppressWarnings(sits_cube_copy(modis_cube, + name = "modis_cube_cp", dest_dir = tempdir(), - bands = "B13", + bands = "EVI", roi = bbox - ) - expect_true(sits_bands(cbers_022024_copy) == "B13") - expect_true(cbers_022024_copy$ncols == 26) - expect_true(cbers_022024_copy$xmin == cbers_022024$xmin) - expect_true(all(sits_timeline(cbers_022024_copy) == - sits_timeline(cbers_022024))) -}) - -test_that("Creating a raster stack cube and renaming bands", { - # Create a raster cube based on CBERS data - data_dir <- system.file("extdata/raster/cbers", package = "sits") - - # create a raster cube file based on the information about the files - cbers_cube2 <- tryCatch({ - sits_cube( - source = "LOCAL", - name = "022024", - origin = "BDC", - collection = "CB4_64-1", - data_dir = data_dir, - delim = "_", - parse_info = c("X1", "X2", "tile", "band", "date") - ) - }, - error = function(e) { - return(NULL) - }) - - testthat::skip_if(purrr::is_null(cbers_cube2), - message = "LOCAL cube not found") - - expect_true(all(sits_bands(cbers_cube2) %in% - c("B13", "B14", "B15", "B16", "CLOUD"))) - sits_bands(cbers_cube2) <- c("BAND13", "BAND14", "BAND15", - "BAND16", "CLOUD") - expect_true(all(sits_bands(cbers_cube2) %in% - c("BAND13", "BAND14", "BAND15", "BAND16", "CLOUD"))) - + )) + expect_true(sits_bands(modis_cube_copy) == "EVI") + expect_true(modis_cube_copy$ncols == 128) + expect_true(modis_cube_copy$xmin == modis_cube$xmin) + expect_true(all(sits_timeline(modis_cube_copy) == + sits_timeline(modis_cube))) }) test_that("Creating a raster stack cube with BDC band names", {