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

Solve conflicts.

parent f7385ec9
......@@ -164,73 +164,7 @@ model_opt_r <- function(k,
if (class(test1)[1] == "numeric") {
test1 <- t(matrix(test1))
}
<<<<<<< HEAD
if (length(levels(as.factor(nam))) < 2) {
=======
if (nrow(test1) == 0) {
break
}
##############################
##############################
which_classes_correct_2 <- which(classes[correct] == 2)
if (length(which_classes_correct_2) == 0) {
if (j == 1) {
break
}
} else {
d2 <- correct[which_classes_correct_2]
###generate new samples from only correctly classified samples [label 2]
p2 <- pbt@coords[d2, ]
pbtn2 <-
as.data.frame(cbind(classes[d2], matrix(p2, ncol = 2)))
sp::coordinates(pbtn2) <- c("V2", "V3")
#sp::proj4string(pbtn2) <- sp::proj4string(pbt)
raster::crs(pbtn2) <- raster::crs(pbt)
poly <- rgeos::gBuffer(spgeom = pbtn2,
width = buffer,
byid = TRUE)
test <- ras_vx$extract(sp = poly)
for (i in 1:length(test)) {
s1 <- dim(test[[i]])[1]
#if (s1 <= 5) {
# test[[i]] <-
# test[[i]]
#} else {
if (s1 > 5) {
set.seed(seed)
test[[i]] <-
test[[i]][sample(c(1:s1), 5, replace = F), ]
}
}
for (i in 1:length(test)) {
if (i == 1) {
co <- raster::xyFromCell(raster, test[[i]][, 1])
} else {
co <- rbind(co, raster::xyFromCell(raster, test[[i]][, 1]))
}
}
pbtn2 <- as.data.frame(cbind(rep(2, nrow(co)), co))
sp::coordinates(pbtn2) <- c("x", "y")
test2 <- as.matrix(do.call(rbind, test)[, -1])
if (ncol(test2) == 1) {
test2 <- t(test2)
}
colnames(test2) <- names(raster)
if (length(which(is.na(test2))) > 0) {
pbtn2 <- pbtn2[complete.cases(test2), ]
test2 <- test2[complete.cases(test2), ]
}
}
if (class(test2)[1] == "numeric") {
test2 <- t(matrix(test2))
}
if (nrow(test2) == 0) {
>>>>>>> d2a87c9a0c6aafd4ebc9d41451efcbb89a41ea1f
break
}
######################################
......
......@@ -86,11 +86,8 @@ multi_Class_Sampling <- function(in.raster,
n_classes,
multiTest = 1,
RGB = c(19, 20, 21),
<<<<<<< HEAD
in.memory = TRUE,
=======
color = c("lightgrey", "orange", "yellow", "limegreen", "forestgreen"),
>>>>>>> d2a87c9a0c6aafd4ebc9d41451efcbb89a41ea1f
overwrite = TRUE,
save_runs = TRUE,
parallel_mode = FALSE,
......@@ -99,7 +96,7 @@ multi_Class_Sampling <- function(in.raster,
# Checks if its a new or a resumed run and asks the user to remove all .tif
# files from the results folder in case of a new run.
if(step == 1){
if (step == 1) {
if (length(list.files(
outPath,
pattern = ".tif$",
......@@ -118,15 +115,6 @@ multi_Class_Sampling <- function(in.raster,
}
input_raster <- in.raster
<<<<<<< HEAD
=======
area <- as(raster::extent(in.raster), 'SpatialPolygons')
area <- sp::SpatialPolygonsDataFrame(area, data.frame(ID = 1:length(area)))
#sp::proj4string(area) <- sp::proj4string(in.raster)
raster::crs(area) <- raster::crs(in.raster)
>>>>>>> d2a87c9a0c6aafd4ebc9d41451efcbb89a41ea1f
col <- colorRampPalette(c("lightgrey",
"orange",
"yellow",
......@@ -166,31 +154,6 @@ multi_Class_Sampling <- function(in.raster,
while (decision == "0") {
for (rs in 1:multiTest) {
########################
<<<<<<< HEAD
maFo_rf <- sample_nb(
raster = in.raster,
nb_samples = seq(init.samples, init.samples, init.samples),
sample_type = sample_type,
nb_mean = nb_models,
nb_it = nb_it,
buffer = buffer,
reference = reference,
model = model,
mtry = mtry,
mod.error = mod.error,
last = last,
seed = seed,
init.seed = init.seed,
in.memory = in.memory,
save_runs = save_runs,
parallel_mode = parallel_mode,
max_num_cores = max_num_cores
)
index <- maFo_rf$index
acc <- maFo_rf$acc
maFo_rf <- maFo_rf$obj
=======
returns <- 1
while (returns != 0) {
decision3 <- ""
......@@ -203,10 +166,11 @@ multi_Class_Sampling <- function(in.raster,
buffer = buffer,
reference = reference,
model = model,
area = area,
mtry = mtry,
mod.error = mod.error,
last = last,
seed = seed,
in.memory = in.memory,
init.seed = init.seed,
save_runs = save_runs,
parallel_mode = parallel_mode,
......@@ -260,7 +224,6 @@ multi_Class_Sampling <- function(in.raster,
}
}
}
>>>>>>> d2a87c9a0c6aafd4ebc9d41451efcbb89a41ea1f
########################
maFo[[rs]] <- maFo_rf
test[[rs]] <- maFo_rf@layer[[1]]
......@@ -321,32 +284,6 @@ multi_Class_Sampling <- function(in.raster,
##########################################################################
} else{
########################
<<<<<<< HEAD
maFo_rf <- sample_nb(
raster = in.raster,
nb_samples = seq(init.samples, init.samples, init.samples),
sample_type = sample_type,
nb_mean = nb_models,
nb_it = nb_it,
buffer = buffer,
reference = reference,
model = model,
mtry = mtry,
mod.error = mod.error,
last = last,
seed = seed,
init.seed = init.seed,
in.memory = in.memory,
save_runs = save_runs,
parallel_mode = parallel_mode,
max_num_cores = max_num_cores
)
index <- maFo_rf$index
acc <- maFo_rf$acc
maFo_rf <- maFo_rf$obj
########################
=======
returns <- 1
while (returns != 0) {
decision3 <- ""
......@@ -359,11 +296,12 @@ multi_Class_Sampling <- function(in.raster,
buffer = buffer,
reference = reference,
model = model,
area = area,
mtry = mtry,
mod.error = mod.error,
last = last,
seed = seed,
init.seed = init.seed,
in.memory = in.memory,
save_runs = save_runs,
parallel_mode = parallel_mode,
max_num_cores = max_num_cores
......@@ -416,9 +354,7 @@ multi_Class_Sampling <- function(in.raster,
}
}
}
>>>>>>> d2a87c9a0c6aafd4ebc9d41451efcbb89a41ea1f
}
dummy <- maFo_rf@layer[[1]]
iplot(
x = dummy,
......@@ -469,11 +405,12 @@ multi_Class_Sampling <- function(in.raster,
buffer = buffer,
reference = reference,
model = model,
area = area,
mtry = mtry,
mod.error = mod.error,
last = last,
seed = seed,
init.seed = init.seed,
in.memory = in.memory,
save_runs = save_runs,
parallel_mode = parallel_mode,
max_num_cores = max_num_cores
......@@ -526,38 +463,6 @@ multi_Class_Sampling <- function(in.raster,
}
}
}
<<<<<<< HEAD
print(paste(
paste("init.samples = ", sample2),
paste("models = ", models2)
))
maFo_rf <- sample_nb(
raster = in.raster,
nb_samples = seq(sample2, sample2, sample2),
sample_type = sample_type,
nb_mean = models2,
nb_it = nb_it,
buffer = buffer,
reference = reference,
model = model,
mtry = mtry,
mod.error = mod.error,
last = last,
seed = seed,
init.seed = init.seed,
in.memory = in.memory,
save_runs = save_runs,
parallel_mode = parallel_mode,
max_num_cores = max_num_cores
)
index <- maFo_rf$index
acc <- maFo_rf$acc
maFo_rf <- maFo_rf$obj
########################
=======
>>>>>>> d2a87c9a0c6aafd4ebc9d41451efcbb89a41ea1f
dummy <- maFo_rf@layer[[1]]
iplot(
x = dummy,
......
Supports Markdown
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