diff --git a/r_app/CI_report_dashboard_planet.Rmd b/r_app/CI_report_dashboard_planet.Rmd index 3e5812c..4d33263 100644 --- a/r_app/CI_report_dashboard_planet.Rmd +++ b/r_app/CI_report_dashboard_planet.Rmd @@ -343,7 +343,7 @@ ggplot(pred_ffs_rf, aes(y = predicted_Tcha, x = tonnage_ha)) + y = "Predicted tonnage/ha (Tcha)") + theme_minimal() -ggplot(pred_rf_current_season, aes(x = Age_days, y = predicted_Tcha, col = field)) + +ggplot(pred_rf_current_season, aes(x = Age_days, y = predicted_Tcha)) + geom_point(size = 2, alpha = 0.6) + # Adjust point size and transparency labs(title = "Predicted Yields for Fields Over 300 Days \nOld Yet to Be Harvested", x = "Age (days)", diff --git a/r_app/Rplots.pdf b/r_app/Rplots.pdf index f098abe..7647a7c 100644 Binary files a/r_app/Rplots.pdf and b/r_app/Rplots.pdf differ diff --git a/r_app/ci_extraction.R b/r_app/ci_extraction.R index 9e63793..f1b4d26 100644 --- a/r_app/ci_extraction.R +++ b/r_app/ci_extraction.R @@ -48,11 +48,23 @@ raster_files <- list.files(planet_tif_folder,full.names = T, pattern = ".tif") filtered_files <- map(dates$days_filter, ~ raster_files[grepl(pattern = .x, x = raster_files)]) %>% compact() %>% flatten_chr() -head(filtered_files) + + # Remove files that do not exist + existing_files <- filtered_files[file.exists(filtered_files)] + + # Check if the list of existing files is empty + if (length(existing_files) == 0) { + message("No files exist for the given date(s).") + stop("Terminating script.") + } + + # Continue with the rest of the script + print(existing_files) + vrt_list <- list() -for (file in filtered_files) { +for (file in existing_files) { v_crop <- create_mask_and_crop(file, field_boundaries, merged_final) emtpy_or_full <- global(v_crop, "notNA") @@ -109,7 +121,7 @@ if (!file.exists(file_path)) { extracted_values <- map(dates$days_filter, ~ extracted_values[grepl(pattern = .x, x = extracted_values)]) %>% compact() %>% flatten_chr() - + pivot_stats <- extracted_values %>% map(readRDS) %>% list_rbind() %>% group_by(sub_field)