@@ -27,12 +27,12 @@ hist.sits <- function(x, ...) {
27
27
# ' @description This is a generic function. Parameters depend on the specific
28
28
# ' type of input.
29
29
# '
30
- # ' @param object Object of classes "raster_cube".
30
+ # ' @param x Object of classes "raster_cube".
31
31
# ' @param ... Further specifications for \link{summary}.
32
32
# ' @param tile Tile to be shown
33
33
# ' @param date Date to be shown
34
34
# ' @param band Band to be shown
35
- # ' @param size. Number of cells to be sampled
35
+ # ' @param size Number of cells to be sampled
36
36
# '
37
37
# ' @return A histogram of one band of data cube.
38
38
# '
@@ -124,7 +124,7 @@ hist.raster_cube <- function(x, ...,
124
124
# ' @description This is a generic function. Parameters depend on the specific
125
125
# ' type of input.
126
126
# '
127
- # ' @param object Object of classes "raster_cube".
127
+ # ' @param x Object of classes "raster_cube".
128
128
# ' @param ... Further specifications for \link{summary}.
129
129
# ' @param tile Tile to be shown
130
130
# ' @param label Label to be shown
@@ -153,8 +153,8 @@ hist.raster_cube <- function(x, ...,
153
153
# ' @export
154
154
hist.probs_cube <- function (x , ... ,
155
155
tile = x [[" tile" ]][[1 ]],
156
- labels = NULL ,
157
- size = 10000 ) {
156
+ label = NULL ,
157
+ size = 100000 ) {
158
158
.check_set_caller(" sits_hist_raster_cube" )
159
159
# Pre-conditional check
160
160
.check_chr_parameter(tile , allow_null = TRUE )
@@ -171,13 +171,13 @@ hist.probs_cube <- function(x, ...,
171
171
# filter the tile to be processed
172
172
tile <- .cube_filter_tiles(cube = x , tiles = tile )
173
173
# check the labels
174
- if (.has(labels )) {
174
+ if (.has(label )) {
175
175
# is this a valid label?
176
- .check_that(labels %in% .tile_labels(tile ),
176
+ .check_that(label %in% .tile_labels(tile ),
177
177
msg = .conf(" messages" , " sits_hist_label" )
178
178
)
179
179
} else {
180
- labels <- .tile_labels(tile )
180
+ label <- .tile_labels(tile )[[ 1 ]]
181
181
}
182
182
# select the file to be plotted
183
183
probs_file <- .tile_path(tile )
@@ -194,28 +194,27 @@ hist.probs_cube <- function(x, ...,
194
194
# read file
195
195
r <- terra :: rast(probs_file )
196
196
# select layer
197
- layers <- layers [labels ]
197
+ layers <- layers [label ]
198
198
values <- terra :: spatSample(r [[layers ]], size = size )
199
199
values <- values * band_scale + band_offset
200
- colnames(values ) <- labels
201
- colors_sits <- .colors_get(labels )
202
- values <- tidyr :: pivot_longer(values , cols = dplyr :: all_of(unname(labels )))
200
+ colnames(values ) <- label
201
+ color_sits <- .colors_get(label )
203
202
# values[["color"]] <- colors_sits[values[["name"]]]
204
203
density_plot <-
205
204
values | >
206
- ggplot2 :: ggplot(ggplot2 :: aes(x = .data [[" value " ]])) +
205
+ ggplot2 :: ggplot(ggplot2 :: aes(x = .data [[label ]])) +
207
206
ggplot2 :: geom_density(
208
- ggplot2 :: aes(color = .data [[" name" ]],
209
- fill = .data [[" name" ]]),
207
+ ggplot2 :: aes(x = .data [[label ]]),
208
+ color = color_sits ,
209
+ fill = color_sits ,
210
210
linewidth = 0.8 ,
211
211
alpha = 0.50
212
212
) +
213
213
ggplot2 :: scale_x_continuous(limits = c(0.0 , 1.0 )) +
214
214
ggplot2 :: xlab(" Probability" ) +
215
215
ggplot2 :: ylab(" " ) +
216
216
ggplot2 :: theme(legend.title = ggplot2 :: element_blank()) +
217
- ggplot2 :: ggtitle(paste(" Distribution of probabilities for labels" ,
218
- paste(labels , collapse = " ," )))
217
+ ggplot2 :: ggtitle(paste(" Distribution of probabilities for label" , label ))
219
218
220
219
return (suppressWarnings(density_plot ))
221
220
}
@@ -258,7 +257,7 @@ hist.probs_cube <- function(x, ...,
258
257
hist.uncertainty_cube <- function (
259
258
x , ... ,
260
259
tile = x [[" tile" ]][[1 ]],
261
- size = 10000 ) {
260
+ size = 100000 ) {
262
261
.check_set_caller(" sits_hist_uncertainty_cube" )
263
262
# Pre-conditional check
264
263
.check_chr_parameter(tile , allow_null = TRUE )
0 commit comments