From d7aa92071987032f7b6b8cddb1d032972b72a49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20S=C3=A1nchez=20Tapia?= <4183062+AndreaSanchezTapia@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:26:33 -0700 Subject: [PATCH] fixes #97 (rgdal was trying to save stacks instead of rasters) --- R/ensemble_model.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/R/ensemble_model.R b/R/ensemble_model.R index 582e51f..69ad1f6 100644 --- a/R/ensemble_model.R +++ b/R/ensemble_model.R @@ -288,13 +288,15 @@ ensemble_model <- function(species_name, #axis_nb <- which(summary_pca$importance["Cumulative Proportion",] >= 0.95)[1] expl <- summary_pca$importance["Cumulative Proportion",1] first_axis <- predict(raw_mean_models, pca_mod, index = 1) - first_axis <- rescale_layer(first_axis) - names(first_axis) <- "pca" - writeRaster(first_axis, + pca_vals <- rescale_layer(first_axis) + pca1 <- raster(pca_vals) + values(pca1) <- values(pca_vals) + names(pca1) <- "pca" + terra::writeRaster(pca1, filename = paste0(ensemble_folder, "/", species_name, - "_ensemble_pca_", round(expl,3), + "_ensemble_pca_", as.character(round(expl,3)), ".tif"), ...) - ensemble_mods <- raster::addLayer(ensemble_mods, first_axis) + ensemble_mods <- raster::addLayer(ensemble_mods, pca1) } if (uncertainty == TRUE) { raw_mean_files <- list.files(final_folder,