From 6efa6b6b05b53403887db69144ac5ac789ac2988 Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 3 Feb 2026 14:56:04 +0100 Subject: [PATCH] "wip" --- r_app/10_create_per_field_tiffs.R | 8 ++++++++ r_app/run_full_pipeline.R | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/r_app/10_create_per_field_tiffs.R b/r_app/10_create_per_field_tiffs.R index 56fd5f9..5d88573 100644 --- a/r_app/10_create_per_field_tiffs.R +++ b/r_app/10_create_per_field_tiffs.R @@ -79,6 +79,14 @@ load_field_boundaries <- function(geojson_path) { } } + # FIX: Validate and repair geometries (handles duplicate vertices, degenerate edges, etc) + invalid_count <- sum(!st_is_valid(fields)) + if (invalid_count > 0) { + smartcane_log(paste("WARNING: Found", invalid_count, "invalid geometry/geometries - attempting repair")) + fields <- st_make_valid(fields) + smartcane_log(paste("Repaired invalid geometries using st_make_valid()")) + } + smartcane_log(paste("Loaded", nrow(fields), "field(s)")) return(fields) } diff --git a/r_app/run_full_pipeline.R b/r_app/run_full_pipeline.R index 4a06d14..d3d1e33 100644 --- a/r_app/run_full_pipeline.R +++ b/r_app/run_full_pipeline.R @@ -30,8 +30,8 @@ # ============================================================================== # *** EDIT THESE VARIABLES *** -end_date <- as.Date("2026-01-07") # or specify: as.Date("2026-01-27") , Sys.Date() -project_dir <- "aura" # project name: "esa", "aura", "angata", "chemba" +end_date <- Sys.Date() # or specify: as.Date("2026-01-27") , Sys.Date() +project_dir <- "angata" # project name: "esa", "aura", "angata", "chemba" data_source <- "merged_tif" # Standard data source directory force_rerun <- FALSE # Set to TRUE to force all scripts to run even if outputs exist # ***************************