diff --git a/r_app/10_create_per_field_tiffs.R b/r_app/10_create_per_field_tiffs.R index 7ee2ee2..50789b3 100644 --- a/r_app/10_create_per_field_tiffs.R +++ b/r_app/10_create_per_field_tiffs.R @@ -50,9 +50,9 @@ # # ============================================================================ - -library(terra) -library(sf) +# Spatial data handling +library(terra) # For raster operations (reading/writing GeoTIFFs, cropping to field boundaries) +library(sf) # For spatial operations (reading field boundaries GeoJSON, masking) # ============================================================================== # LOAD CENTRALIZED PARAMETERS & PATHS diff --git a/r_app/20_ci_extraction.R b/r_app/20_ci_extraction.R index d5acc79..17186a5 100644 --- a/r_app/20_ci_extraction.R +++ b/r_app/20_ci_extraction.R @@ -57,14 +57,17 @@ # 1. Load required packages # ----------------------- suppressPackageStartupMessages({ - library(sf) - library(terra) - library(tidyverse) - library(lubridate) - library(readxl) - library(here) - library(furrr) - library(future) + # Spatial data handling + library(sf) # For reading/manipulating field boundaries (GeoJSON) + library(terra) # For raster operations (CI extraction from TIFFs) + + # Data manipulation + library(tidyverse) # For dplyr, ggplot2, readr (data wrangling and visualization) + library(lubridate) # For date/time operations (parsing satellite dates) + + # File I/O + library(readxl) # For reading harvest.xlsx (harvest dates for field mapping) + library(here) # For relative path resolution (platform-independent file paths) }) # 2. Process command line arguments diff --git a/r_app/21_convert_ci_rds_to_csv.R b/r_app/21_convert_ci_rds_to_csv.R index 7c8e740..0fe5a35 100644 --- a/r_app/21_convert_ci_rds_to_csv.R +++ b/r_app/21_convert_ci_rds_to_csv.R @@ -50,10 +50,13 @@ # ============================================================================ suppressPackageStartupMessages({ - library(tidyverse) - library(lubridate) - library(zoo) - library(here) + # File path handling + library(here) # For relative path resolution (platform-independent file paths) + + # Data manipulation + library(tidyverse) # For dplyr, readr (data wrangling and CSV I/O) + library(lubridate) # For date/time operations (DOY calculation) + library(zoo) # For zoo objects (gap filling, rolling operations) }) # ============================================================================ diff --git a/r_app/30_interpolate_growth_model.R b/r_app/30_interpolate_growth_model.R index 2b4bcc7..a6617bd 100644 --- a/r_app/30_interpolate_growth_model.R +++ b/r_app/30_interpolate_growth_model.R @@ -53,9 +53,12 @@ # 1. Load required packages # ----------------------- suppressPackageStartupMessages({ - library(tidyverse) - library(lubridate) - library(here) + # File path handling + library(here) # For relative path resolution (platform-independent file paths) + + # Data manipulation + library(tidyverse) # For dplyr (data wrangling, grouping, mutating) + library(lubridate) # For date/time operations (date arithmetic, ISO week extraction) }) # ============================================================================= diff --git a/r_app/40_mosaic_creation.R b/r_app/40_mosaic_creation.R index 669277c..cdf269e 100644 --- a/r_app/40_mosaic_creation.R +++ b/r_app/40_mosaic_creation.R @@ -60,11 +60,16 @@ # 1. Load required packages # ----------------------- suppressPackageStartupMessages({ - library(sf) - library(terra) - library(tidyverse) - library(lubridate) - library(here) + # File path handling + library(here) # For relative path resolution (platform-independent file paths) + + # Spatial data handling + library(sf) # For spatial operations (field boundary masking) + library(terra) # For raster operations (reading/writing/stacking GeoTIFFs) + + # Data manipulation + library(tidyverse) # For dplyr, readr (data wrangling) + library(lubridate) # For date/time operations (week extraction, date formatting) }) # 2. Process command line arguments and run mosaic creation diff --git a/r_app/80_calculate_kpis.R b/r_app/80_calculate_kpis.R index 7c96f9e..5586782 100644 --- a/r_app/80_calculate_kpis.R +++ b/r_app/80_calculate_kpis.R @@ -127,23 +127,26 @@ WEEKS_FOR_CV_TREND_LONG <- 8 # ============================================================================ suppressPackageStartupMessages({ - library(here) - library(sf) - library(terra) - library(dplyr) - library(tidyr) - library(lubridate) - library(readr) - library(readxl) - library(writexl) - library(purrr) - library(furrr) - library(future) - library(caret) - library(CAST) - library(randomForest) + # File path handling + library(here) # For relative path resolution (platform-independent file paths) + + # Spatial data handling + library(sf) # For reading/manipulating field boundaries (GeoJSON) + library(terra) # For raster operations (reading mosaic TIFFs) + + # Data manipulation + library(dplyr) # For data wrangling (filter, mutate, group_by, summarize) + library(tidyr) # For data reshaping (pivot_longer, pivot_wider, gather) + library(lubridate) # For date/time operations (week extraction, date arithmetic) + + # File I/O + library(readr) # For reading CSV files (harvest predictions from Python) + library(readxl) # For reading harvest.xlsx (harvest dates for field mapping) + library(writexl) # For writing Excel outputs (KPI summary tables) + + # ML/Analysis (optional - only for harvest model inference) tryCatch({ - library(torch) + library(torch) # For PyTorch model inference (harvest readiness prediction) }, error = function(e) { message("Note: torch package not available - harvest model inference will be skipped") }) diff --git a/r_app/90_CI_report_with_kpis_simple.Rmd b/r_app/90_CI_report_with_kpis_simple.Rmd index 363ef18..1fc6b89 100644 --- a/r_app/90_CI_report_with_kpis_simple.Rmd +++ b/r_app/90_CI_report_with_kpis_simple.Rmd @@ -38,21 +38,26 @@ reporting_script <- TRUE # Load all packages at once with suppressPackageStartupMessages suppressPackageStartupMessages({ - library(here) - library(sf) - library(terra) - library(tidyverse) - library(tmap) - library(lubridate) - library(zoo) - library(rsample) - library(caret) - library(randomForest) - library(CAST) - library(knitr) - library(tidyr) - library(flextable) - library(officer) + # File path handling + library(here) # For relative path resolution (platform-independent file paths) + + # Spatial data handling + library(sf) # For reading/manipulating field boundaries (GeoJSON) + library(terra) # For raster operations (reading mosaic TIFFs for visualization) + + # Data manipulation + library(tidyverse) # For dplyr, ggplot2, tidyr (data wrangling and visualization) + library(tidyr) # For data reshaping (pivot_longer, pivot_wider for wide-to-long conversion) + library(lubridate) # For date/time operations (week extraction, date formatting) + library(zoo) # For zoo objects (time series manipulation, na.locf for gap filling) + + # Visualization + library(tmap) # For interactive maps (field boundary visualization) + + # Reporting + library(knitr) # For R Markdown document generation (code execution and output) + library(flextable) # For formatted tables in Word output (professional table styling) + library(officer) # For Word document manipulation (custom formatting, headers, footers) }) # Load custom utility functions diff --git a/r_app/91_CI_report_with_kpis_Angata.Rmd b/r_app/91_CI_report_with_kpis_Angata.Rmd index ace4167..fff958b 100644 --- a/r_app/91_CI_report_with_kpis_Angata.Rmd +++ b/r_app/91_CI_report_with_kpis_Angata.Rmd @@ -38,20 +38,25 @@ reporting_script <- TRUE # Load all packages at once with suppressPackageStartupMessages suppressPackageStartupMessages({ - library(here) - library(sf) - library(terra) - library(tidyverse) - library(tmap) - library(lubridate) - library(zoo) - library(rsample) - library(caret) - library(randomForest) - library(CAST) - library(knitr) - library(tidyr) - library(flextable) + # File path handling + library(here) # For relative path resolution (platform-independent file paths) + + # Spatial data handling + library(sf) # For reading/manipulating field boundaries (GeoJSON) + library(terra) # For raster operations (reading mosaic TIFFs for visualization) + + # Data manipulation + library(tidyverse) # For dplyr, ggplot2, tidyr (data wrangling and visualization) + library(tidyr) # For data reshaping (pivot_longer, pivot_wider for wide-to-long conversion) + library(lubridate) # For date/time operations (week extraction, date formatting) + library(zoo) # For zoo objects (time series manipulation, na.locf for gap filling) + + # Visualization + library(tmap) # For interactive maps (field boundary visualization) + + # Reporting + library(knitr) # For R Markdown document generation (code execution and output) + library(flextable) # For formatted tables in Word output (professional table styling) }) # Load custom utility functions