Skip to content

Commit 4f9d04a

Browse files
committed
fix merge conflicts
2 parents 02d7160 + fb85f44 commit 4f9d04a

8 files changed

+95
-24
lines changed

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ export(sits_smooth)
494494
export(sits_som_clean_samples)
495495
export(sits_som_evaluate_cluster)
496496
export(sits_som_map)
497+
export(sits_som_remove_samples)
497498
export(sits_stats)
498499
export(sits_stratified_sampling)
499500
export(sits_svm)

R/api_conf.R

+12-12
Original file line numberDiff line numberDiff line change
@@ -547,24 +547,24 @@
547547
#' @param source Data source
548548
#'
549549
#' @return Called for side effects.
550-
.conf_list_source <- function(s){
551-
cat(paste0(s, ":\n"))
552-
collections <- .source_collections(source = s)
553-
purrr::map(collections, function(c) {
554-
cat(paste0("- ", c))
550+
.conf_list_source <- function(source){
551+
cat(paste0(source, ":\n"))
552+
collections <- .source_collections(source)
553+
purrr::map(collections, function(col) {
554+
cat(paste0("- ", col))
555555
cat(paste0(
556-
" (", .source_collection_satellite(s, c),
557-
"/", .source_collection_sensor(s, c), ")\n",
558-
"- grid system: ", .source_collection_grid_system(s, c), "\n"
556+
" (", .source_collection_satellite(source, col),
557+
"/", .source_collection_sensor(source, col), ")\n",
558+
"- grid system: ", .source_collection_grid_system(source, col), "\n"
559559
))
560560
cat("- bands: ")
561-
cat(.source_bands(s, c))
561+
cat(.source_bands(source, col))
562562
cat("\n")
563-
if (.source_collection_open_data(source = s, collection = c)) {
563+
if (.source_collection_open_data(source, col)) {
564564
cat("- opendata collection ")
565565
if (.source_collection_open_data(
566-
source = s,
567-
collection = c,
566+
source = source,
567+
collection = col,
568568
token = TRUE
569569
)) {
570570
cat("(requires access token)")

R/api_plot_raster.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
dimension = "band",
267267
maxColorValue = max_value,
268268
use_alpha = FALSE,
269-
probs = c(fst_quant, las_quant),
269+
probs = c(fst_quant, lst_quant),
270270
stretch = TRUE
271271
)
272272
# tmap params

R/sits_config.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ sits_config <- function(config_user_file = NULL) {
6464
}
6565
#' @title Show current sits configuration
6666
#' @name sits_config_show
67-
#' @param source Data source (character vector).
68-
#' @param collection Collection (character vector).
6967
#'
7068
#' @description
7169
#' Prints the current sits configuration options.
@@ -94,7 +92,7 @@ sits_config_show <- function() {
9492
config_view <- sits_env[["config"]][["view"]]
9593
.conf_list_params(config_view)
9694

97-
cat("User sits_config_user_file() to create a user configuration file")
95+
cat("Use sits_config_user_file() to create a user configuration file")
9896
return(invisible(NULL))
9997
}
10098

@@ -138,12 +136,14 @@ sits_list_collections <- function(source = NULL) {
138136
#' @title List the cloud collections supported by sits
139137
#' @name sits_config_user_file
140138
#' @param file_path file to store the user configuration file
139+
#' @param overwrite replace current configurarion file?
141140
#' @description
142141
#' Creates a user configuration file.
143142
#'
144143
#' @return Called for side effects
145144
#' @examples
146-
#' sits_config_user_file(tempdir(), "my_config_file.yml")
145+
#' user_file <- paste0(tempdir(), "/my_config_file.yml")
146+
#' sits_config_user_file(user_file)
147147
#' @export
148148
sits_config_user_file <- function(file_path, overwrite = FALSE){
149149
# get default user configuration file
@@ -181,7 +181,7 @@ sits_config_user_file <- function(file_path, overwrite = FALSE){
181181

182182
if (update)
183183
warning(.conf("messages", "sits_config_user_file_updated"))
184-
else if (newfile)
184+
else if (new_file)
185185
warning(.conf("messages", "sits_config_user_file_new_file"))
186186
else
187187
warning(.conf("messages", "sits_config_user_file_no_update"))

R/sits_som.R

+39
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,42 @@ sits_som_evaluate_cluster <- function(som_map) {
371371
)
372372
return(purity_by_cluster)
373373
}
374+
#' @title Evaluate cluster
375+
#' @name sits_som_remove_samples
376+
#' @description
377+
#' Remove samples from a given class inside a neuron of another class
378+
#' @param som_map A SOM map produced by the som_map() function
379+
#' @param som_eval An evaluation produced by the som_eval() function
380+
#' @param class_cluster Dominant class of a set of neurons
381+
#' @param class_remove Class to be removed from the neurons of the "class_cluster"
382+
#' @return A new set of samples with the desired class neurons remove
383+
#' @examples
384+
#' if (sits_run_examples()) {
385+
#' # create a som map
386+
#' som_map <- sits_som_map(samples_modis_ndvi)
387+
#' # evaluate the som map and create clusters
388+
#' som_eval <- sits_som_evaluate_cluster(som_map)
389+
#' # clean the samples
390+
#' new_samples <- sits_som_remove_samples(som_map, som_eval, "Pasture", "Cerrado")
391+
#' }
392+
#' @export
393+
sits_som_remove_samples <- function(som_map, som_eval, class_cluster, class_remove){
394+
395+
# get the samples with id_neuron
396+
data <- som_map$data
397+
# get the samples by neurons
398+
neurons <- som_map$labelled_neurons
399+
400+
neurons_class_1 <- dplyr::filter(neurons, .data[["label_samples"]] == class_cluster
401+
& .data[["prior_prob"]] > 0.50)
402+
id_neurons_class_1 <- neurons_class_1[["id_neuron"]]
403+
# find samples of class2 in neurons of class1
404+
samples_remove <- dplyr::filter(data, .data[["label"]] == class_remove &
405+
.data[["id_neuron"]] %in% id_neurons_class_1)
406+
# get the id of the samples to be removed
407+
id_samples_remove <- samples_remove[["id_sample"]]
408+
# obtain the new samples
409+
new_samples <- dplyr::filter(data, !(.data[["id_sample"]] %in% id_samples_remove))
410+
# return the new samples
411+
return(new_samples)
412+
}

man/sits_config_show.Rd

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

man/sits_config_user_file.Rd

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

man/sits_som_remove_samples.Rd

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

0 commit comments

Comments
 (0)