Commit 2b7e90b8 authored by Romulo Pereira Goncalves's avatar Romulo Pereira Goncalves
Browse files

Only pass one raster, and the one that is in memory.

parent f5b1bf63
......@@ -112,7 +112,7 @@ sample_nb <- function(raster,
res <- parallel::mclapply(
1:nb_mean,
model_opt_r,
raster = raster,
raster = rast,
sample_type = sample_type,
buffer = buffer,
model = model,
......@@ -124,7 +124,6 @@ sample_nb <- function(raster,
mtry = mtry,
mod.error = mod.error,
pbtn1 = pbtn1,
rast = rast,
max_samples_per_class = max_samples_per_class,
mc.cores = cores,
mc.preschedule = TRUE,
......@@ -138,7 +137,7 @@ sample_nb <- function(raster,
} else {
for (k in 1:nb_mean) {
res <- model_opt_r(
raster = raster,
raster = rast,
sample_type = sample_type,
buffer = buffer,
model = model,
......@@ -151,7 +150,6 @@ sample_nb <- function(raster,
mtry = mtry,
mod.error = mod.error,
pbtn1 = pbtn1,
rast = rast,
max_samples_per_class = max_samples_per_class
)
points_list[[k]] <- res$points
......
......@@ -15,7 +15,6 @@
#' @param mtry number of predictor used at random forest splitting nodes (mtry << n predictors)
#' @param mod.error threshold for model error until which iteration is being executed
#' @param pbtn1 matrix for points
#' @param rast raster
#' @param max_samples_per_class maximum number of samples per class
#'
#' @return a list with 4 elements:
......@@ -37,12 +36,11 @@ model_opt_r <- function(k,
mtry,
mod.error,
pbtn1,
rast,
max_samples_per_class) {
points <- NULL
models <- NULL
oobe <- matrix(NA, nrow = n, ncol = 1)
rast <- raster::mask(rast, raster::calc(rast, fun = sum))
rast <- raster::mask(raster, raster::calc(raster, fun = sum))
for (j in 1:n) {
###Vorbereitung Klassifizierung
if (j == 1) {
......@@ -152,7 +150,7 @@ model_opt_r <- function(k,
nam <-
as.vector(fasterize::fasterize(sf::st_as_sf(poly), rast[[1]], field = "V1"))[-attr(test1, "na.action")]
co<-raster::xyFromCell(rast, c(1:raster::ncell(rast))[-attr(test1,"na.action")])
co <- raster::xyFromCell(rast, c(1:raster::ncell(rast))[-attr(test1,"na.action")])
pbtn1 <- as.data.frame(cbind(nam, co))
sp::coordinates(pbtn1) <- c("x", "y")
......
......@@ -18,7 +18,6 @@ model_opt_r(
mtry,
mod.error,
pbtn1,
rast,
max_samples_per_class
)
}
......@@ -49,8 +48,6 @@ model_opt_r(
\item{pbtn1}{matrix for points}
\item{rast}{raster}
\item{max_samples_per_class}{maximum number of samples per class}
}
\value{
......
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