diff --git a/r_app/.gitignore b/r_app/.gitignore index eac6522..c5916ee 100644 --- a/r_app/.gitignore +++ b/r_app/.gitignore @@ -16,4 +16,5 @@ renv .Rprofile # Ignore OSX files .DS_Store +CI_report_dashboard_planet_files diff --git a/r_app/2_CI_data_prep.R b/r_app/2_CI_data_prep.R index 1706267..dc320f4 100644 --- a/r_app/2_CI_data_prep.R +++ b/r_app/2_CI_data_prep.R @@ -11,7 +11,6 @@ library(lubridate) library(exactextractr) library(CIprep) -source(here("r_app", "parameters_project.R")) # Vang alle command line argumenten op args <- commandArgs(trailingOnly = TRUE) @@ -57,6 +56,8 @@ weekly_CI_mosaic <- here(laravel_storage_dir, "weekly_mosaic") daily_vrt <- here(data_dir, "vrt") harvest_dir <- here(data_dir, "HarvestData") +source(here("r_app", "parameters_project.R")) + dir.create(here(laravel_storage_dir)) dir.create(here(data_dir)) dir.create(here(extracted_CI_dir)) @@ -134,6 +135,12 @@ create_mask_and_crop <- function(file, field_boundaries) { vrt_list <- list() +# for (file in raster_files) { +# v_crop <- create_mask_and_crop(file, field_boundaries) +# message(file, " processed") +# gc() +# } + for (file in filtered_files) { v_crop <- create_mask_and_crop(file, field_boundaries) emtpy_or_full <- global(v_crop, "notNA") @@ -271,14 +278,14 @@ if (new_project_question == TRUE) { pivot_stats <- extracted_values %>% map(readRDS) %>% list_rbind() %>% - group_by(pivot_quadrant) %>% + group_by(subField) %>% summarise(across(everything(), ~ first(na.omit(.)))) saveRDS(pivot_stats, here(cumulative_CI_vals_dir,"combined_CI_data.rds")) #used to save the rest of the data into one file pivot_stats2 <- pivot_stats - print("All CI values extracted from allhistoric images") + print("All CI values extracted from all historic images") } else { print("combined_CI_data.rds exists, adding the latest image data to the table.") @@ -309,15 +316,15 @@ if (new_project_question == TRUE) { # gather data into long format for easier calculation and visualisation pivot_stats_long <- pivot_stats2 %>% - tidyr::gather("Date", value, -pivot_quadrant, -pivot ) %>% + tidyr::gather("Date", value, -Field, -subField, -sub_area ) %>% mutate(Date = right(Date, 8), Date = lubridate::ymd(Date) ) %>% drop_na(c("value","Date")) %>% mutate(value = as.numeric(value))%>% filter_all(all_vars(!is.infinite(.))) %>% - rename(Field = pivot_quadrant, - subField = Field) %>% + # rename(Field = pivot_quadrant, + # subField = Field) %>% unique() diff --git a/r_app/CI_Report_dashboard_planet.html b/r_app/CI_Report_dashboard_planet.html index 3ab3f97..f90065a 100644 --- a/r_app/CI_Report_dashboard_planet.html +++ b/r_app/CI_Report_dashboard_planet.html @@ -11,7 +11,7 @@ -CI dashboard week 40 - all pivots dashboard using 3x3 meter resolution +CI_report_dashboard_planet.knit + +