sc 114 library formatting and cleaning

This commit is contained in:
Timon 2026-02-04 09:44:08 +01:00
parent 85d2f11ed6
commit 5c29c9b549
8 changed files with 95 additions and 68 deletions

View file

@ -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

View file

@ -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

View file

@ -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)
})
# ============================================================================

View file

@ -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)
})
# =============================================================================

View file

@ -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

View file

@ -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")
})

View file

@ -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

View file

@ -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