Skip to content

Commit 7547eb5

Browse files
update plot for vector and uncertainty data cubes
1 parent 99f120e commit 7547eb5

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

R/api_select.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,15 @@
6262
}
6363
return(data)
6464
}
65+
#' @title Select tiles from cube
6566
#' @noRd
66-
#' @name .select_raster_cube
6767
#' @param data Data cube.
6868
#' @param bands Character vector with the names of the bands.
6969
#' @param start_date Date in YYYY-MM-DD format: start date to be filtered.
7070
#' @param end_date Date in YYYY-MM-DD format: end date to be filtered.
7171
#' @param dates Character vector with sparse dates to select.
7272
#' @param tiles Character vector with the names of the tiles.
73+
#' @return selected lines of the data cube tibble
7374
#'
7475
.select_raster_cube <- function(data,
7576
bands = NULL,

R/sits_plot.R

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ plot.raster_cube <- function(x, ...,
526526
#' @param rev Reverse the color order in the palette?
527527
#' @param scale Scale to plot map (0.4 to 1.5)
528528
#' @param style Style for plotting continuous objects
529+
#' @param first_quantile First quantile for stretching images
530+
#' @param last_quantile Last quantile for stretching images
529531
#' @param max_cog_size Maximum size of COG overviews (lines or columns)
530532
#' @return A plot object with an RGB image
531533
#' or a B/W image on a color
@@ -534,8 +536,6 @@ plot.raster_cube <- function(x, ...,
534536
#' @note The following optional parameters are available to allow for detailed
535537
#' control over the plot output:
536538
#' \itemize{
537-
#' \item \code{first_quantile}: 1st quantile for stretching images (default = 0.05)
538-
#' \item \code{last_quantile}: last quantile for stretching images (default = 0.95)
539539
#' \item \code{graticules_labels_size}: size of coordinates labels (default = 0.8)
540540
#' \item \code{legend_title_size}: relative size of legend title (default = 1.0)
541541
#' \item \code{legend_text_size}: relative size of legend text (default = 1.0)
@@ -573,11 +573,13 @@ plot.vector_cube <- function(x, ...,
573573
tile = x[["tile"]][[1]],
574574
dates = NULL,
575575
seg_color = "black",
576-
line_width = 0.3,
576+
line_width = 0.2,
577577
palette = "RdYlGn",
578578
rev = FALSE,
579-
scale = 1.0,
580-
style = "order",
579+
scale = 0.8,
580+
style = "cont",
581+
first_quantile = 0.02,
582+
last_quantile = 0.98,
581583
max_cog_size = 1024) {
582584
.check_set_caller(".plot_vector_cube")
583585
# retrieve dots
@@ -630,6 +632,8 @@ plot.vector_cube <- function(x, ...,
630632
rev = rev,
631633
scale = scale,
632634
style = style,
635+
first_quantile = first_quantile,
636+
last_quantile = last_quantile,
633637
max_cog_size = max_cog_size,
634638
tmap_params = tmap_params
635639
)
@@ -898,6 +902,9 @@ plot.variance_cube <- function(x, ...,
898902
#' @param palette An RColorBrewer palette
899903
#' @param rev Reverse the color order in the palette?
900904
#' @param scale Scale to plot map (0.4 to 1.0)
905+
#' @param style Style for plotting continuous objects
906+
#' @param first_quantile First quantile for stretching images
907+
#' @param last_quantile Last quantile for stretching images
901908
#' @param max_cog_size Maximum size of COG overviews (lines or columns)
902909

903910
#'
@@ -907,8 +914,6 @@ plot.variance_cube <- function(x, ...,
907914
#' @note The following optional parameters are available to allow for detailed
908915
#' control over the plot output:
909916
#' \itemize{
910-
#' \item \code{first_quantile}: 1st quantile for stretching images (default = 0.05)
911-
#' \item \code{last_quantile}: last quantile for stretching images (default = 0.95)
912917
#' \item \code{graticules_labels_size}: size of coordinates labels (default = 0.8)
913918
#' \item \code{legend_title_size}: relative size of legend title (default = 1.0)
914919
#' \item \code{legend_text_size}: relative size of legend text (default = 1.0)
@@ -944,7 +949,10 @@ plot.uncertainty_cube <- function(x, ...,
944949
tile = x[["tile"]][[1]],
945950
palette = "RdYlGn",
946951
rev = TRUE,
947-
scale = 1.0,
952+
scale = 0.8,
953+
style = "cont",
954+
first_quantile = 0.02,
955+
last_quantile = 0.98,
948956
max_cog_size = 1024) {
949957
.check_set_caller(".plot_uncertainty_cube")
950958
# get tmap params from dots
@@ -976,7 +984,9 @@ plot.uncertainty_cube <- function(x, ...,
976984
main_title = main_title,
977985
rev = rev,
978986
scale = scale,
979-
style = "order",
987+
style = style,
988+
first_quantile = first_quantile,
989+
last_quantile = last_quantile,
980990
max_cog_size = max_cog_size,
981991
tmap_params = tmap_params
982992
)

man/plot.uncertainty_cube.Rd

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot.vector_cube.Rd

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-plot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test_that("Plot Time Series and Images", {
4646
progress = FALSE
4747
)
4848
p <- plot(sinop, band = "NDVI", palette = "RdYlGn")
49-
expect_equal(p$tm_shape$shp_name, "rast")
49+
expect_equal(p$tm_shape$shp_name, "st")
5050
expect_equal(p$tm_raster$palette, "RdYlGn")
5151
expect_equal(p$tm_grid$grid.projection, 4326)
5252

0 commit comments

Comments
 (0)