Skip to content

Commit 1e883bf

Browse files
authored
Merge pull request #442 from OldLipe/dev
Fix bugs in v0.15.0
2 parents 224892f + ec73082 commit 1e883bf

11 files changed

+36
-15
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: sits
22
Type: Package
3-
Version: 0.15.0
3+
Version: 0.15.0-1
44
Title: Satellite Image Time Series Analysis for Remote Sensing Data Cubes
55
Authors@R: c(person('Rolf', 'Simoes', role = c('aut'), email = '[email protected]'),
66
person('Gilberto', 'Camara', role = c('aut', 'cre'), email = '[email protected]'),

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ We are preparing to release the package on CRAN and are making relevant changes
44

55
# What's new in SITS version 0.15.0
66

7+
### New features in SITS version 0.15.0-1
8+
* Fix bug in `sits_plot`
9+
* Fix bug in `sits_timeline` for cubes that do not have the same temporal extent.
10+
711
### New features in SITS version 0.15.0
812

913
* Support for regularization of collections in DEAFRICA and USGS improvement

R/sits_plot.R

+12-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ plot.predicted <- function(x, y, ..., bands = "NDVI") {
126126
#' @param red band for red color.
127127
#' @param green band for green color.
128128
#' @param blue band for blue color.
129+
#' @param tile tile number to be plotted
129130
#' @param time temporal instances to be plotted.
130131
#' @param roi sf object giving a region of interest.
131132
#'
@@ -136,9 +137,19 @@ plot.raster_cube <- function(x, ...,
136137
red,
137138
green,
138139
blue,
140+
tile = 1,
139141
time = 1,
140142
roi = NULL) {
141143

144+
# precondition
145+
.check_num(
146+
tile, min = 1, max = nrow(x), is_integer = TRUE,
147+
len_min = 1, len_max = 1,
148+
msg = "invalid tile parameter"
149+
)
150+
# select only one tile
151+
x <- x[tile, ]
152+
142153
if (!purrr::is_null(band)) {
143154
red = band
144155
green = band
@@ -197,7 +208,7 @@ plot.raster_cube <- function(x, ...,
197208
rgb_stack <- c(red_file, green_file, blue_file)
198209
}
199210
# use the raster package to obtain a raster object from a stack
200-
r_obj <- .raster_open_stack.raster(rgb_stack)
211+
r_obj <- .raster_open_stack.terra(rgb_stack)
201212

202213
# extract region of interest
203214
if (!purrr::is_null(roi)) {

R/sits_timeline.R

+12-10
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ sits_timeline.sits <- function(data) {
3131
#'
3232
sits_timeline.raster_cube <- function(data) {
3333

34-
timeline_first <- unique(lubridate::as_date(data$file_info[[1]]$date))
35-
36-
slider::slide(data, function(tile) {
34+
# pick the list of timelines
35+
timelines.lst <- slider::slide(data, function(tile) {
3736
timeline_tile <- unique(lubridate::as_date(tile$file_info[[1]]$date))
38-
.check_that(
39-
x = all(timeline_tile %in% timeline_first),
40-
msg = "data cube tiles have different timelines"
41-
)
37+
return(timeline_tile)
4238
})
43-
44-
# return the timeline of the cube
45-
return(timeline_first)
39+
names(timelines.lst) <- data$tile
40+
timeline_unique <- unname(unique(timelines.lst))
41+
42+
if (length(timeline_unique) == 1)
43+
return(timeline_unique[[1]])
44+
else {
45+
warning("Cube is not regular. Returning all timelines")
46+
return(timelines.lst)
47+
}
4648
}
4749

4850
#' @export

R/sits_view.R

+2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ sits_view.raster_cube <- function(x, ...,
134134
palette = "default") {
135135

136136
# preconditions
137+
# pick only the selected tile
138+
x <- x[tile,]
137139
# verifies if leafem and leaflet packages are installed
138140
.check_that(
139141
requireNamespace("leafem", quietly = TRUE),

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ as in the following example.
164164

165165
``` r
166166
library(sits)
167-
#> Using configuration file: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/sits/extdata/config.yml
167+
#> Using configuration file: /home/sits/R/x86_64-pc-linux-gnu-library/4.1/sits/extdata/config.yml
168168
#> To provide additional configurations, create an YAML file and inform its path to environment variable 'SITS_CONFIG_USER_FILE'.
169169
#> Using raster package: terra
170170
#> SITS - satellite image time series analysis.
171-
#> Loaded sits v0.15.0.
171+
#> Loaded sits v0.15.0-1.
172172
#> See ?sits for help, citation("sits") for use in publication.
173173
#> See demo(package = "sits") for examples.
174174
# create a cube from a local file
-13.7 KB
Loading
-15 KB
Loading
-7.52 KB
Loading
-15.3 KB
Loading

man/plot.raster_cube.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)