From 41c97c9ba09d87281bbbf64a53cc7e27b24d232b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Julio=20Rinc=C3=B3n-Parra?= Date: Thu, 18 Jul 2024 10:49:09 -0500 Subject: [PATCH] update Occ_model_resultsv3 --- .../occ_model_resultsv3/occ_model_resultsv3.R | 17 ++++++++++++++++- .../occ_model_resultsv3/occ_model_resultsv3.yml | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/occ_model_resultsv3/occ_model_resultsv3.R b/scripts/occ_model_resultsv3/occ_model_resultsv3.R index 980abb6a..041897e7 100644 --- a/scripts/occ_model_resultsv3/occ_model_resultsv3.R +++ b/scripts/occ_model_resultsv3/occ_model_resultsv3.R @@ -101,15 +101,30 @@ occ_avg<- if(nrow(test_models)<=1){ + + + + ########## #Prediction ########## # Load data of prediction surface - site_covs_Layers<- input$site_covs_Layers %>% setNames(basename(tools::file_path_sans_ext(.))) + site_covs_Layers<- lapply(input$site_covs_Layers, function(y) { text_ext<- tools::file_ext(y) + if(text_ext != ""){ + if(file.exists(y)){y}else{NULL} + } else { + test_folder<- dir.exists(y) + if(test_folder){ list.files(y, full.names = T, recursive = F, pattern = "\\.tif$") %>% {.[!grepl("\\.tfw$|~$", .)]} } else { NULL } + } + }) %>% unlist() %>% setNames(basename(tools::file_path_sans_ext(.))) + spatial_pred_surface<- site_covs_Layers[ names(site_covs_Layers) %>% {.[. %in% site_covs]} ] %>% terra::rast() %>% setNames(site_covs) + + + id_cells<- terra::cells(spatial_pred_surface) pred_surface <- spatial_pred_surface[id_cells] diff --git a/scripts/occ_model_resultsv3/occ_model_resultsv3.yml b/scripts/occ_model_resultsv3/occ_model_resultsv3.yml index d2a4c56f..2765b394 100644 --- a/scripts/occ_model_resultsv3/occ_model_resultsv3.yml +++ b/scripts/occ_model_resultsv3/occ_model_resultsv3.yml @@ -16,7 +16,7 @@ inputs: label: site_covs_Layers description: "List of site variables (site/landscape characteristics that influence species detection and occupancy). They can be specified by name or through the directory where they are stored in .tif format. Names must match the columns in camptrap_data or will be omitted." type: image/tiff;application=geotiff[] - example: ["scripts/occ_model_resultsv3/input/"] + example: ["scripts/occ_model_resultsv3/input/dir_stack"] obs_covs: label: obs_covs description: "List of observation variables (hour, lunar phase, climate) that must match columns in camptrap_data or will be omitted. As they can vary by event, they must be grouped/collapsed for the unmarked object. When they are factors, they are not rounded. Numeric variables are specified as eventTime|1, where 1 is the rounding value. For temporal variables, use eventTime|1|hour. Temporal units from lubridate::round_date are accepted."