Skip to content

Commit d0629b9

Browse files
authored
Merge pull request #903 from rolfsimoes/hotfix/stars
Hotfix/stars
2 parents 7788b45 + 4e2b357 commit d0629b9

File tree

8 files changed

+76
-46
lines changed

8 files changed

+76
-46
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: sits
22
Type: Package
3-
Version: 1.2.0-2
3+
Version: 1.2.0-3
44
Title: Satellite Image Time Series Analysis for Earth Observation 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]'),
@@ -99,7 +99,7 @@ Config/testthat/start-first: cube, raster, ml
9999
LinkingTo:
100100
Rcpp,
101101
RcppArmadillo
102-
RoxygenNote: 7.2.1
102+
RoxygenNote: 7.2.3
103103
Collate:
104104
'RcppExports.R'
105105
'data.R'

NEWS.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
# What's new in SITS version 1.2.0
44

5+
### Hotfix version 1.2.0-3
6+
* Fix `stars` proxy bug (issue #902)
7+
* Fix `purrr` cross deprecation
8+
* Fix `ggplot2` aes_string deprecation
9+
510
### Hotfix version 1.2.0-2
611
* Fix `tibble` subsetting bug (issue #893)
712

R/sits_chunks.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ NULL
4343
#' @returns A tibble with chunks.
4444
.chunks_create <- function(block, overlap, image_size, image_bbox) {
4545
# Generate all starting block points (col, row)
46-
chunks <- purrr::cross_df(list(
46+
chunks <- tidyr::expand_grid(
4747
col = seq(1, .ncols(image_size), .ncols(block)),
4848
row = seq(1, .nrows(image_size), .nrows(block))
49-
))
49+
)
5050
# Adjust col and row to do overlap
5151
chunks[["col"]] <- .as_int(pmax(1, .col(chunks) - overlap))
5252
chunks[["row"]] <- .as_int(pmax(1, .row(chunks) - overlap))

R/sits_gdalcubes.R

+10-2
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,11 @@
708708
# do a cross product on tiles and bands
709709
tiles_bands_times <- unlist(slider::slide(cube, function(tile) {
710710
bands <- .cube_bands(tile, add_cloud = FALSE)
711-
purrr::cross3(.cube_tiles(tile), bands, timeline)
711+
tidyr::expand_grid(tile = .cube_tiles(tile), band = bands,
712+
time = timeline) %>%
713+
purrr::pmap(function(tile, band, time) {
714+
return(list(tile, band, time))
715+
})
712716
}), recursive = FALSE)
713717

714718
# if regularized cube does not exist, return all tiles from original cube
@@ -719,7 +723,11 @@
719723
# do a cross product on tiles and bands
720724
gc_tiles_bands_times <- unlist(slider::slide(local_cube, function(tile) {
721725
bands <- .cube_bands(tile, add_cloud = FALSE)
722-
purrr::cross3(.cube_tiles(tile), bands, timeline)
726+
tidyr::expand_grid(tile = .cube_tiles(tile), band = bands,
727+
time = timeline) %>%
728+
purrr::pmap(function(tile, band, time) {
729+
return(list(tile, band, time))
730+
})
723731
}), recursive = FALSE)
724732

725733
# first, include tiles and bands that have not been processed

R/sits_get_data.R

+10-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ sits_get_data.data.frame <- function(cube,
418418
# get cubes timeline
419419
tl <- sits_timeline(cube)
420420

421-
tiles_bands <- purrr::cross2(.cube_tiles(cube), bands)
421+
tiles_bands <- tidyr::expand_grid(tile = .cube_tiles(cube),
422+
band = bands) %>%
423+
purrr::pmap(function(tile, band) {
424+
return(list(tile, band))
425+
})
422426

423427
# prepare parallelization
424428
.sits_parallel_start(workers = multicores, log = FALSE)
@@ -617,7 +621,11 @@ sits_get_data.data.frame <- function(cube,
617621
# get cubes timeline
618622
tl <- sits_timeline(cube)
619623

620-
tiles_bands <- purrr::cross2(.cube_tiles(cube), bands)
624+
tiles_bands <- tidyr::expand_grid(tile = .cube_tiles(cube),
625+
band = bands) %>%
626+
purrr::pmap(function(tile, band) {
627+
return(list(tile, band))
628+
})
621629

622630
# prepare parallelization
623631
.sits_parallel_start(workers = multicores, log = FALSE)

R/sits_plot.R

+36-29
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,17 @@ plot.sits <- function(x, y, ...) {
351351
ggplot2::geom_line(
352352
data = means,
353353
ggplot2::aes(x = .data[["Index"]], y = .data[["med"]]),
354-
colour = "#B16240", size = 2, inherit.aes = FALSE
354+
colour = "#B16240", linewidth = 2, inherit.aes = FALSE
355355
) +
356356
ggplot2::geom_line(
357357
data = means,
358358
ggplot2::aes(x = .data[["Index"]], y = .data[["qt25"]]),
359-
colour = "#B19540", size = 1, inherit.aes = FALSE
359+
colour = "#B19540", linewidth = 1, inherit.aes = FALSE
360360
) +
361361
ggplot2::geom_line(
362362
data = means,
363363
ggplot2::aes(x = .data[["Index"]], y = .data[["qt75"]]),
364-
colour = "#B19540", size = 1, inherit.aes = FALSE
364+
colour = "#B19540", linewidth = 1, inherit.aes = FALSE
365365
)
366366
return(g)
367367
}
@@ -430,10 +430,10 @@ plot.patterns <- function(x, y, ...) {
430430
plot.df <- tidyr::pivot_longer(plot.df, cols = sits_bands(x))
431431

432432
# Plot temporal patterns
433-
gp <- ggplot2::ggplot(plot.df, ggplot2::aes_string(
434-
x = "Time",
435-
y = "value",
436-
colour = "name"
433+
gp <- ggplot2::ggplot(plot.df, ggplot2::aes(
434+
x = .data[["Time"]],
435+
y = .data[["value"]],
436+
colour = .data[["name"]]
437437
)) +
438438
ggplot2::geom_line() +
439439
ggplot2::facet_wrap(~Pattern) +
@@ -567,21 +567,21 @@ plot.predicted <- function(x, y, ...,
567567
) +
568568
ggplot2::geom_polygon(
569569
data = df_pol,
570-
ggplot2::aes_string(
571-
x = "Time",
572-
y = "value",
573-
group = "Group",
574-
fill = "Class"
570+
ggplot2::aes(
571+
x = .data[["Time"]],
572+
y = .data[["value"]],
573+
group = .data[["Group"]],
574+
fill = .data[["Class"]]
575575
),
576576
alpha = .7
577577
) +
578578
ggplot2::scale_fill_manual(values = colors) +
579579
ggplot2::geom_line(
580580
data = df_x,
581-
ggplot2::aes_string(
582-
x = "Time",
583-
y = "value",
584-
colour = "variable"
581+
ggplot2::aes(
582+
x = .data[["Time"]],
583+
y = .data[["value"]],
584+
colour = .data[["variable"]]
585585
)
586586
) +
587587
ggplot2::scale_color_brewer(palette = "Set1") +
@@ -951,9 +951,11 @@ plot.class_cube <- function(x, y, ...,
951951
stars_obj <- stars::read_stars(
952952
bw_file,
953953
RasterIO = list(
954-
"nBufXSize" = size["xsize"],
955-
"nBufYSize" = size["ysize"]
956-
))
954+
"nBufXSize" = size[["xsize"]],
955+
"nBufYSize" = size[["ysize"]]
956+
),
957+
proxy = FALSE
958+
)
957959

958960
# rescale the stars object
959961
stars_obj <- stars_obj * .conf("raster_cube_scale_factor")
@@ -1024,9 +1026,11 @@ plot.class_cube <- function(x, y, ...,
10241026
stars_obj <- stars::read_stars(
10251027
class_file,
10261028
RasterIO = list(
1027-
"nBufXSize" = size["xsize"],
1028-
"nBufYSize" = size["ysize"]
1029-
))
1029+
"nBufXSize" = size[["xsize"]],
1030+
"nBufYSize" = size[["ysize"]]
1031+
),
1032+
proxy = FALSE
1033+
)
10301034

10311035
# rename stars object
10321036
stars_obj <- stats::setNames(stars_obj, "labels")
@@ -1104,9 +1108,10 @@ plot.class_cube <- function(x, y, ...,
11041108
probs_st <- stars::read_stars(
11051109
probs_path,
11061110
RasterIO = list(
1107-
"nBufXSize" = size["xsize"],
1108-
"nBufYSize" = size["ysize"]
1109-
)
1111+
"nBufXSize" = size[["xsize"]],
1112+
"nBufYSize" = size[["ysize"]]
1113+
),
1114+
proxy = FALSE
11101115
)
11111116
# get the band
11121117
band <- .tile_bands(tile)
@@ -1170,9 +1175,11 @@ plot.class_cube <- function(x, y, ...,
11701175
c(red_file, green_file, blue_file),
11711176
along = "band",
11721177
RasterIO = list(
1173-
"nBufXSize" = size["xsize"],
1174-
"nBufYSize" = size["ysize"]
1175-
))
1178+
"nBufXSize" = size[["xsize"]],
1179+
"nBufYSize" = size[["ysize"]]
1180+
),
1181+
proxy = FALSE
1182+
)
11761183
# get the max values
11771184
band_params <- .tile_band_conf(tile, red)
11781185
max_value <- .max_value(band_params)
@@ -1739,7 +1746,7 @@ plot.geo_distances <- function(x, y, ...) {
17391746
color = .data[["type"]],
17401747
fill = .data[["type"]]
17411748
),
1742-
lwd = 1, alpha = 0.25
1749+
linewidth = 1, alpha = 0.25
17431750
) +
17441751
ggplot2::scale_x_log10(labels = scales::label_number()) +
17451752
ggplot2::xlab("Distance (km)") +

R/sits_view.R

+10-8
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ sits_view.raster_cube <- function(x, ...,
457457
rgb_files,
458458
along = "band",
459459
RasterIO = list(
460-
"nBufXSize" = output_size["xsize"],
461-
"nBufYSize" = output_size["ysize"]
460+
"nBufXSize" = output_size[["xsize"]],
461+
"nBufYSize" = output_size[["ysize"]]
462462
),
463463
proxy = FALSE
464464
)
@@ -517,9 +517,10 @@ sits_view.raster_cube <- function(x, ...,
517517
.tile_path(tile),
518518
RAT = labels,
519519
RasterIO = list(
520-
"nBufXSize" = output_size["xsize"],
521-
"nBufYSize" = output_size["ysize"]
522-
)
520+
"nBufXSize" = output_size[["xsize"]],
521+
"nBufYSize" = output_size[["ysize"]]
522+
),
523+
proxy = FALSE
523524
)
524525
})
525526

@@ -634,9 +635,10 @@ sits_view.class_cube <- function(x, ...,
634635
.tile_path(tile),
635636
RAT = labels,
636637
RasterIO = list(
637-
"nBufXSize" = output_size["xsize"],
638-
"nBufYSize" = output_size["ysize"]
639-
)
638+
"nBufXSize" = output_size[["xsize"]],
639+
"nBufYSize" = output_size[["ysize"]]
640+
),
641+
proxy = FALSE
640642
)
641643
})
642644

inst/extdata/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ gdalcubes_options : ["COMPRESS=LZW", "PREDICTOR=2",
2929
# maxbytes per plot (in MB)
3030
plot_max_Mbytes: 10
3131
# max_cells for tmap (in number of cells)
32-
tmap_max_cells: 1e+07
32+
tmap_max_cells: 1e+06
3333
# maxbytes for leaflet (in MB)
3434
leaflet_max_megabytes : 64
3535
# estimated compression factor for leaflet

0 commit comments

Comments
 (0)