SmartCane/r_app/experiments/interactive_sar_visualization/SAR_quick_test.Rmd
2025-09-05 15:23:41 +02:00

70 lines
1.5 KiB
Plaintext

---
title: "SAR Analysis - Quick Test"
output:
html_document:
self_contained: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
# Check working directory
if (basename(getwd()) == "r_app") {
setwd("..")
}
```
# Quick SAR Test
```{r test-loading}
# Test basic loading
cat("Testing SAR data loading...\n")
library(terra, quietly = TRUE)
library(sf, quietly = TRUE)
library(tmap, quietly = TRUE)
# Load field boundaries
field_boundaries <- st_read("pivot.geojson", quiet = TRUE)
cat("Loaded", nrow(field_boundaries), "fields\n")
# Load one SAR file
sar_file <- "python_scripts/data/aura/weekly_SAR_mosaic/week_33_2025_VV_dB_filtered.tif"
if (file.exists(sar_file)) {
sar_data <- rast(sar_file)
cat("✓ SAR data loaded:", dim(sar_data), "\n")
# Set tmap to interactive mode
tmap_mode("view")
# Create simple interactive map
map <- tm_shape(sar_data) +
tm_raster(
title = "VV Backscatter (dB)",
palette = "viridis",
alpha = 0.8
) +
tm_shape(field_boundaries) +
tm_polygons(
alpha = 0.2,
col = "lightblue",
border.col = "white",
border.lwd = 2,
popup.vars = c("Field" = "Name"),
id = "Name"
) +
tm_layout(title = "SAR Week 33 - Interactive Test")
map
} else {
cat("✗ SAR file not found\n")
}
```
**Interactive Features:**
- Zoom in/out with mouse wheel
- Pan by dragging
- Click on field boundaries for popup info
- Toggle layers with layer control
- Different base maps available