Commit a290cbd4 authored by Romulo Pereira Goncalves's avatar Romulo Pereira Goncalves
Browse files

Merge branch 'issue#22' into 'master'

Fixes for #20 and improvements like suggested in #22

Closes #20

See merge request !11
parents d2e29a93 20fbb72b
Pipeline #24177 passed with stages
in 3 minutes and 55 seconds
......@@ -366,6 +366,7 @@ multi_Class_Sampling <- function(in.raster,
g = RGB[2],
b = RGB[3],
num_models = num_models,
nb_models = nb_models,
acc = acc,
color = color,
outPath = outPath,
......@@ -473,6 +474,7 @@ multi_Class_Sampling <- function(in.raster,
g = RGB[2],
b = RGB[3],
num_models = num_models,
nb_models = nb_models,
acc = acc,
color = color,
outPath = outPath,
......@@ -519,9 +521,7 @@ multi_Class_Sampling <- function(in.raster,
raster::KML(kml, paste(outPath, paste("step_", ni, sep = ""), sep = ""), overwrite = overwrite)
thres <- as.numeric(decision)
dummy <- maFo_rf@layer[[1]]
max_prob <- raster::cellStats(dummy, "max")
thres <- (max_prob/100) * thres
thres <- thres + num_models
dummy[dummy < thres] <- 1
dummy[dummy >= thres] <- NA
in.raster <- in.raster * dummy
......@@ -532,7 +532,7 @@ multi_Class_Sampling <- function(in.raster,
out.raster <<- in.raster
remove(dummy)
remove(maFo_rf)
print(paste(paste("Habitat", i), "Done"))
colnames(reference) <- names(in.raster)
......
......@@ -10,6 +10,7 @@
#' @param b blue channel (integer)
#' @param acc predictive accuracy (integer)
#' @param num_models number of selected models
#' @param nb_models number of models (independent classifiers) for the specification in the legend
#' @param color color pallet
#' @param outPath file path for '.html export (character)
#' @param plot_on_browser plot on the browser or inline in a notebook (default TRUE)
......@@ -24,6 +25,7 @@ iplot <- function(x,
b,
acc,
num_models,
nb_models,
color,
outPath,
plot_on_browser = TRUE) {
......@@ -125,11 +127,10 @@ iplot <- function(x,
######
rr <- x
raster::values(rr) <- 1:raster::ncell(rr)
max <- raster::cellStats(x, "max") - num_models
x <- raster::calc(
x,
fun = function(y)
round(((y - num_models) / max) * 100, digits = 2)
(y - num_models)
)
##############################################################################
##[2] Create Leaflet Html output for Webbrowser
......@@ -166,16 +167,28 @@ iplot <- function(x,
layerId = HaTy,
prefix = "Habitat Type"
)
mv <- leaflet::addLegend(
map = mv,
"bottomright",
pal = pal,
labFormat = leaflet::labelFormat( suffix = "%",),
values = c(0, 100),
title = paste("Habitat Type Probability<br>(for ", num_models, " models)", sep = ""),
opacity = 1
)
if (num_models<11) {
mv <- leaflet::addLegend(
map = mv,
"bottomright",
pal = pal,
labFormat = leaflet::labelFormat(suffix = " Models",
transform = function(x) seq(0, num_models, 1)),
values = c(0, num_models),
title = paste("Number of models (", num_models," out of ", nb_models,")<br>predicting class ", HaTy, sep = ""),
opacity = 1
)
} else {
mv <- leaflet::addLegend(
map = mv,
"bottomright",
pal = pal,
labFormat = leaflet::labelFormat(suffix = " Models"),
values = c(0, num_models),
title = paste("Number of models (", num_models," out of ", nb_models,")<br>predicting class ", HaTy, sep = ""),
opacity = 1
)
}
mv <- leaflet::addLayersControl(map = mv,
overlayGroups = c("RGB Composite", HaTy))
......
......@@ -13,6 +13,7 @@ iplot(
b,
acc,
num_models,
nb_models,
color,
outPath,
plot_on_browser = TRUE
......@@ -35,6 +36,8 @@ iplot(
\item{num_models}{number of selected models}
\item{nb_models}{number of models (independent classifiers) for the specification in the legend}
\item{color}{color pallet}
\item{outPath}{file path for '.html export (character)}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment