Skip to content

Commit

Permalink
Merge pull request #392 from e-sensing/dev
Browse files Browse the repository at this point in the history
Release v0.14.1
  • Loading branch information
gilbertocamara authored Sep 26, 2021
2 parents a02159d + 5acaff0 commit c38eb6f
Show file tree
Hide file tree
Showing 118 changed files with 1,314 additions and 537 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ Meta
*.bkp
Makevars
Makevars.*
*.json
*.gcda
*.gcno
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down Expand Up @@ -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'
Expand Down
14 changes: 14 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/sits_bands.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 28 additions & 13 deletions R/sits_bands_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/sits_classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 51 additions & 1 deletion R/sits_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit c38eb6f

Please sign in to comment.