Skip to content

Commit

Permalink
Merge pull request #442 from OldLipe/dev
Browse files Browse the repository at this point in the history
Fix bugs in v0.15.0
  • Loading branch information
rolfsimoes authored Oct 26, 2021
2 parents 224892f + ec73082 commit 1e883bf
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sits
Type: Package
Version: 0.15.0
Version: 0.15.0-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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ We are preparing to release the package on CRAN and are making relevant changes

# What's new in SITS version 0.15.0

### New features in SITS version 0.15.0-1
* Fix bug in `sits_plot`
* Fix bug in `sits_timeline` for cubes that do not have the same temporal extent.

### New features in SITS version 0.15.0

* Support for regularization of collections in DEAFRICA and USGS improvement
Expand Down
13 changes: 12 additions & 1 deletion R/sits_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ plot.predicted <- function(x, y, ..., bands = "NDVI") {
#' @param red band for red color.
#' @param green band for green color.
#' @param blue band for blue color.
#' @param tile tile number to be plotted
#' @param time temporal instances to be plotted.
#' @param roi sf object giving a region of interest.
#'
Expand All @@ -136,9 +137,19 @@ plot.raster_cube <- function(x, ...,
red,
green,
blue,
tile = 1,
time = 1,
roi = NULL) {

# precondition
.check_num(
tile, min = 1, max = nrow(x), is_integer = TRUE,
len_min = 1, len_max = 1,
msg = "invalid tile parameter"
)
# select only one tile
x <- x[tile, ]

if (!purrr::is_null(band)) {
red = band
green = band
Expand Down Expand Up @@ -197,7 +208,7 @@ plot.raster_cube <- function(x, ...,
rgb_stack <- c(red_file, green_file, blue_file)
}
# use the raster package to obtain a raster object from a stack
r_obj <- .raster_open_stack.raster(rgb_stack)
r_obj <- .raster_open_stack.terra(rgb_stack)

# extract region of interest
if (!purrr::is_null(roi)) {
Expand Down
22 changes: 12 additions & 10 deletions R/sits_timeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ sits_timeline.sits <- function(data) {
#'
sits_timeline.raster_cube <- function(data) {

timeline_first <- unique(lubridate::as_date(data$file_info[[1]]$date))

slider::slide(data, function(tile) {
# pick the list of timelines
timelines.lst <- slider::slide(data, function(tile) {
timeline_tile <- unique(lubridate::as_date(tile$file_info[[1]]$date))
.check_that(
x = all(timeline_tile %in% timeline_first),
msg = "data cube tiles have different timelines"
)
return(timeline_tile)
})

# return the timeline of the cube
return(timeline_first)
names(timelines.lst) <- data$tile
timeline_unique <- unname(unique(timelines.lst))

if (length(timeline_unique) == 1)
return(timeline_unique[[1]])
else {
warning("Cube is not regular. Returning all timelines")
return(timelines.lst)
}
}

#' @export
Expand Down
2 changes: 2 additions & 0 deletions R/sits_view.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ sits_view.raster_cube <- function(x, ...,
palette = "default") {

# preconditions
# pick only the selected tile
x <- x[tile,]
# verifies if leafem and leaflet packages are installed
.check_that(
requireNamespace("leafem", quietly = TRUE),
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ as in the following example.

``` r
library(sits)
#> Using configuration file: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/sits/extdata/config.yml
#> Using configuration file: /home/sits/R/x86_64-pc-linux-gnu-library/4.1/sits/extdata/config.yml
#> 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.15.0.
#> Loaded sits v0.15.0-1.
#> See ?sits for help, citation("sits") for use in publication.
#> See demo(package = "sits") for examples.
# create a cube from a local file
Expand Down
Binary file modified man/figures/README-unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion man/plot.raster_cube.Rd

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

0 comments on commit 1e883bf

Please sign in to comment.