if (FALSE) {
# These examples require actual spectral data
# Comprehensive corn analysis
corn_analysis <- analyze_crop_vegetation(
spectral_data = sentinel_data,
crop_type = "corn",
analysis_type = "comprehensive",
cdl_mask = corn_mask
)
# Access results
corn_analysis$vegetation_indices # SpatRaster with indices
corn_analysis$analysis_results$stress_analysis # Stress detection results
corn_analysis$metadata$indices_used # Which indices were calculated
# Stress detection in soybeans
stress_analysis <- analyze_crop_vegetation(
spectral_data = landsat_stack,
crop_type = "soybeans",
analysis_type = "stress",
growth_stage = "mid"
)
}
# \donttest{
# Example with mock spectral data
# Create mock multi-band raster (simulating satellite data)
red_band <- terra::rast(nrows = 5, ncols = 5, crs = "EPSG:4326")
nir_band <- terra::rast(nrows = 5, ncols = 5, crs = "EPSG:4326")
terra::values(red_band) <- runif(25, 0.1, 0.3) # Typical red values
terra::values(nir_band) <- runif(25, 0.4, 0.8) # Typical NIR values
spectral_stack <- c(red_band, nir_band)
names(spectral_stack) <- c("red", "nir")
# Analyze with mock data
result <- analyze_crop_vegetation(spectral_stack, crop_type = "general")
print(names(result)) # Should show analysis components
# }
Run the code above in your browser using DataLab