diff --git a/R/api_plot_raster.R b/R/api_plot_raster.R index 36bea5e3..5dc6d4d3 100644 --- a/R/api_plot_raster.R +++ b/R/api_plot_raster.R @@ -112,6 +112,8 @@ #' @param rev Reverse the color palette? #' @param scale Scale to plot map (0.4 to 1.0) #' @param max_cog_size Maximum size of COG overviews (lines or columns) +#' @param first_quantile First quantile for stretching images +#' @param last_quantile Last quantile for stretching images #' @param tmap_params List with tmap params for detailed plot control #' #' @return A list of plot objects @@ -124,6 +126,8 @@ rev, scale, max_cog_size, + first_quantile, + last_quantile, tmap_params) { # crop using ROI if (.has(roi)) { @@ -154,11 +158,13 @@ green_file = green_file, blue_file = blue_file, sizes = sizes, - max_value = max_value, sf_seg = NULL, seg_color = NULL, line_width = NULL, scale = scale, + max_value = max_value, + first_quantile = first_quantile, + last_quantile = last_quantile, tmap_params = tmap_params ) return(p) @@ -178,6 +184,8 @@ #' @param line_width Line width to plot the segments boundary #' @param scale Scale to plot map (0.4 to 1.0) #' @param max_cog_size Maximum size of COG overviews (lines or columns) +#' @param first_quantile First quantile for stretching images +#' @param last_quantile Last quantile for stretching images #' @param tmap_params List with tmap params for detailed plot control #' @return A plot object #' @@ -192,6 +200,8 @@ line_width, scale, max_cog_size, + first_quantile, + last_quantile, tmap_params) { # crop using ROI @@ -224,11 +234,13 @@ green_file = green_file, blue_file = blue_file, sizes = sizes, - max_value = max_value, sf_seg = sf_seg, seg_color = seg_color, line_width = line_width, scale = scale, + max_value = max_value, + first_quantile = first_quantile, + last_quantile = last_quantile, tmap_params = tmap_params ) return(p) @@ -242,11 +254,13 @@ #' @param green_file File to be plotted in green #' @param blue_file File to be plotted in blue #' @param sizes Image sizes for overview -#' @param max_value Maximum value #' @param sf_seg Segments (sf object) #' @param seg_color Color to use for segment borders #' @param line_width Line width to plot the segments boundary #' @param scale Scale to plot map (0.4 to 1.0) +#' @param max_value Maximum value +#' @param first_quantile First quantile for stretching images +#' @param last_quantile Last quantile for stretching images #' @param tmap_params List with tmap params for detailed plot control #' @return A plot object #' @@ -254,11 +268,13 @@ green_file, blue_file, sizes, - max_value, sf_seg, seg_color, line_width, scale, + max_value, + first_quantile, + last_quantile, tmap_params) { # read raster data as a stars object with separate RGB bands @@ -274,6 +290,9 @@ p <- .tmap_rgb_color( rgb_st = rgb_st, scale = scale, + max_value = max_value, + first_quantile = first_quantile, + last_quantile = last_quantile, tmap_params = tmap_params, sf_seg = sf_seg, seg_color = seg_color, diff --git a/R/api_tmap.R b/R/api_tmap.R index ef95b661..2b158cf9 100644 --- a/R/api_tmap.R +++ b/R/api_tmap.R @@ -60,19 +60,24 @@ #' @keywords internal #' @noRd #' @param rgb_st RGB stars object. +#' @param scale Scale to plot map (0.4 to 1.0) +#' @param max_value Maximum value +#' @param first_quantile First quantile for stretching images +#' @param last_quantile Last quantile for stretching images +#' @param tmap_params List with tmap params for detailed plot control #' @param sf_seg Segments (sf object) #' @param seg_color Color to use for segment borders #' @param line_width Line width to plot the segments boundary -#' @param scale Scale to plot map (0.4 to 1.0) -#' @param tmap_params List with tmap params for detailed plot control #' @return A list of plot objects .tmap_rgb_color <- function(rgb_st, + scale, + max_value, + first_quantile, + last_quantile, + tmap_params, sf_seg, seg_color, - line_width, - scale, - tmap_params) { - + line_width) { if (as.numeric_version(utils::packageVersion("tmap")) < "3.9") class(rgb_st) <- "tmap_v3" else diff --git a/R/api_tmap_v3.R b/R/api_tmap_v3.R index e0d96e93..03ecec43 100644 --- a/R/api_tmap_v3.R +++ b/R/api_tmap_v3.R @@ -69,10 +69,24 @@ return(p) } #' @export -.tmap_rgb_color.tmap_v3 <- function(rgb_st, ..., - sf_seg, seg_color, line_width, - scale, tmap_params) { +.tmap_rgb_color.tmap_v3 <- function(rgb_st, + scale, + max_value, + first_quantile, + last_quantile, + tmap_params, + sf_seg, + seg_color, + line_width) { + # open RGB stars + rgb_st <- stars::st_rgb(rgb_st[, , , 1:3], + dimension = "band", + maxColorValue = max_value, + use_alpha = FALSE, + probs = c(first_quantile, last_quantile), + stretch = TRUE + ) # tmap params labels_size <- tmap_params[["graticules_labels_size"]] diff --git a/R/api_tmap_v4.R b/R/api_tmap_v4.R index d0aa08e8..b339ca9a 100644 --- a/R/api_tmap_v4.R +++ b/R/api_tmap_v4.R @@ -93,11 +93,14 @@ } #' @export .tmap_rgb_color.tmap_v4 <- function(rgb_st, + scale, + max_value, + first_quantile, + last_quantile, + tmap_params, sf_seg, seg_color, - line_width, - scale, - tmap_params) { + line_width) { p <- tmap::tm_shape(rgb_st, raster.downsample = FALSE) + tmap::tm_rgb( @@ -105,8 +108,8 @@ col.scale = tmap::tm_scale_rgb( value.na = NA, stretch = TRUE, - probs = c(0.05, 0.95), - maxColorValue = 1.0 + probs = c(first_quantile, last_quantile), + maxColorValue = max_value ) ) + tmap::tm_graticules( diff --git a/R/sits_plot.R b/R/sits_plot.R index fab82ce7..beb20320 100644 --- a/R/sits_plot.R +++ b/R/sits_plot.R @@ -442,11 +442,13 @@ plot.raster_cube <- function(x, ..., tile = tile, band = band, dates = dates, + roi = roi, palette = palette, rev = rev, scale = scale, max_cog_size = max_cog_size, - roi = roi, + first_quantile = first_quantile, + last_quantile = last_quantile, tmap_params = tmap_params ) return(p) @@ -485,6 +487,8 @@ plot.raster_cube <- function(x, ..., line_width = NULL, scale = scale, max_cog_size = max_cog_size, + first_quantile = first_quantile, + last_quantile = last_quantile, tmap_params = tmap_params ) } diff --git a/R/zzz.R b/R/zzz.R index e51bbab9..be9ea224 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -8,19 +8,15 @@ Documentation avaliable in %s.", utils::packageDescription("sits")[["Version"]], "https://e-sensing.github.io/sitsbook/" + ) ) - if (Sys.info()["sysname"] == "Darwin") { - if (grepl("4.4", R.version.string)) { - packageStartupMessage( - sprintf( - "Running R-4.4 on MacOS. - Please read section \"Fixing problems in MacOS\" in + packageStartupMessage( + sprintf( + "Important: Please read \"Release Notes for SITS 1.5.2\" in https://github.com/e-sensing/sits." ) - ) - } - } + ) } .onLoad <- function(lib, pkg) { Sys.setenv(R_CONFIG_FILE = "config.yml") diff --git a/inst/extdata/torch/download_new_torch.R b/inst/extdata/torch/download_new_torch.R new file mode 100644 index 00000000..a10cabc0 --- /dev/null +++ b/inst/extdata/torch/download_new_torch.R @@ -0,0 +1,8 @@ +options(timeout = 600) +kind <- "cpu-intel" +version <- "0.13.0.9001" +options(repos = c( + torch = sprintf("https://torch-cdn.mlverse.org/packages/%s/%s/", kind, version), + CRAN = "https://cloud.r-project.org" # or any other from which you want to install the other R dependencies. +)) +install.packages("torch", type = "binary")