AI Decision System
Replayable, offline-verifiable records for AI-assisted go/no-go decisions: experiment promotions, typed model answers and human-approved actions.
翻譯準備中
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證Download and analyze FAO WaPOR v3 and AgERA5: seasonal CWP, Shiny dashboard, DuckDB monitoring
翻譯準備中
取自儲存庫 README
正在載入完整 README。 以下為已儲存的摘錄。
Rwapor: Satellite Data Ingestion & Water Productivity Analysis in R
Rwapor is a high-performance R package for streaming, analyzing, and visualizing satellite data from FAO WaPOR v3 (Water Productivity Open-access portal) and ECMWF AgERA5 agro-meteorological indicators.
It provides both a complete programmatic R API and an interactive Shiny dashboard with DuckDB analytics, tiled raster processing, agronomic crop modeling (FAO-56), and spatial water stress anomaly detection.檢視完整 README ↗Rwapor is a high-performance R package for streaming, analyzing, and visualizing satellite data from FAO WaPOR v3 (Water Productivity Open-access portal) and ECMWF AgERA5 agro-meteorological indicators.
It provides both a complete programmatic R API and an interactive Shiny dashboard with DuckDB analytics, tiled raster processing, agronomic crop modeling (FAO-56), and spatial water stress anomaly detection.
No programming experience? The Installation guide below walks you through everything from scratch, and the Quick Start section gets you to a point-and-click dashboard with no coding at all.
/vsicurl/ with automatic HTTP range-request chunking and persistent 24h disk caching.wapor_pixel_area_ha()) ensuring latitude-unbiased class and AOI statistics on geographic (EPSG:4326) grids.wapor_run_seasonal_analysis_tiled() windows sources onto square tiles, writes a versioned run manifest, and assembles GeoTIFF/COG products with a VRT. Peak memory is bounded by tile size, not the full AOI.exactextractr and embedded DuckDB storage for multi-year farm monitoring.This guide assumes no prior R experience. Follow the steps in order for your operating system. The whole process takes about 10–15 minutes.
Already have R and RStudio installed? Skip to Step 3: Install Rwapor.
R is the free statistical programming language Rwapor runs on.
.pkg installer that matches your Mac: arm64 for Apple
Silicon (M1/M2/M3/M4, most Macs sold since late 2020) or the Intel build
for older machines. If unsure, check Apple menu → About This Mac..pkg file and follow the installer.Open a terminal and run:
sudo apt-get update
sudo apt-get install -y --no-install-recommends r-base r-base-dev
For Fedora/RHEL/CentOS, use sudo dnf install R instead.
RStudio is a free, beginner-friendly application for writing and running R code — you'll use it for everything below. It works identically on Windows, macOS, and Linux.
Copy each code block below into the RStudio Console, one at a time, pressing Enter after each. If a popup asks whether to update other packages, choose "All" (or press a then Enter if asked in the Console).
3.1 — Install system geospatial libraries (Linux only)
Rwapor depends on terra and sf, which need the GDAL, PROJ, and GEOS
geospatial libraries. Windows and macOS CRAN packages already include these,
so Windows and macOS users can skip straight to 3.2.
sudo apt-get update
sudo apt-get install -y libgdal-dev libproj-dev libgeos-dev libudunits2-dev libssl-dev libcurl4-openssl-dev
(Fedora/RHEL: sudo dnf install gdal-devel proj-devel geos-devel udunits2-devel openssl-devel libcurl-devel)
3.2 — Install the required R packages
In the RStudio Console:
install.packages(c(
# Geospatial & API Core
"terra", "sf", "httr2", "jsonlite", "dplyr", "purrr",
"lubridate", "exactextractr", "memoise", "future", "future.apply", "digest",
# Interactive Dashboard & Database
"shiny", "bslib", "leaflet", "leaflet.extras", "leaflet.extras2",
"shinyFiles", "shinyvalidate", "shinyjs", "shinyAce", "DT",
"shinycssloaders", "promises", "duckdb", "DBI",
# Visualization & Data
"ggplot2", "tidyterra", "patchwork", "ggspatial", "viridisLite",
"RColorBrewer", "arrow",
# Vignettes (needed for build_vignettes = TRUE in 3.3)
"knitr", "rmarkdown"
))
This step downloads and compiles several packages, so it can take a few minutes the first time — that's normal.
3.3 — Install Rwapor from GitHub
install.packages("remotes") # if not already installed
remotes::install_github("almutaz9000/Rwapor", build_vignettes = TRUE)
Building the vignettes needs knitr, rmarkdown and Pandoc. RStudio ships
Pandoc; outside RStudio, if the install stops with a Pandoc or vignette error,
install without them (the vignettes are also on the
package website):
remotes::install_github("almutaz9000/Rwapor")
library(Rwapor)
wapor_variable_metadata("L1-AETI-D")
If this prints a table of variable metadata with no errors, Rwapor is installed correctly. Jump to Quick Start to launch the point-and-click dashboard.
xcode-select --install in the Terminal app, then retry.-dev/-devel system library is the most common cause.Restart RStudio after installing R (Step 1) so it detects the new
installation. On Windows/macOS this is automatic; on Linux, confirm with
R --version in a terminal that R is on your PATH.
Open a GitHub issue with your
operating system, R version (R.version.string in the Console), and the
full error message — see Getting Help.
Launch the full interactive point-and-click GUI directly from R:
library(Rwapor)
# Launch Shiny application
run_wapor()
# Or specify a custom default working directory for downloaded data
run_wapor(data_folder = "C:/WaPOR_Projects")
📥 Download & Spatial Extraction:
🌾 Seasonal Analysis & Crop Productivity:
📈 Seasonal Comparison:
🛰️ High-Throughput Field Monitoring:
🗺️ Split-Screen Map Visualizer:
Download satellite data and extract polygon zonal statistics in parallel:
library(Rwapor)
library(future)
# Enable parallel background workers
plan(multisession, workers = 4)
# Define vector file (Shapefile, GeoJSON, or GeoPackage)
fields_path <- "farm_parcels.geojson"
# Extract dekadal actual evapotranspiration (Level 2, ~100m)
ts_data <- wapor_ts(
region = fields_path,
variable = "L2-AETI-D",
period = c("2023-01-01", "2023-12-31"),
identifier = "plot_id",
unit_conversion = "unit_conversion" # Converts daily rates (mm/day) to dekadal totals (mm)
)
head(ts_data)
# Write results to CSV
write.csv(ts_data, "aeti_timeseries.csv", row.names = FALSE)
Define custom crop coefficients without relying strictly on FAO defaults:
library(Rwapor)
# Option A: Build a completely custom crop from scratch
custom_crop <- wapor_create_crop_params(
class_value = 1L,
crop_name = "Local High-Yield Durum Wheat",
kc_ini = 0.35,
kc_mid = 1.25,
kc_end = 0.30,
l_ini_days = 25L,
l_mid_days = 50L,
l_late_days = 30L,
HI = 0.50, # Harvest Index
MC = 0.12 # Moisture Content
)
# Option B: Override specific factors from an FAO profile
custom_maize <- wapor_custom_crop(
base_crop = "Maize",
class_value = 2L,
crop_name = "Irrigated Hybrid Maize",
kc_mid = 1.30,
HI = 0.55
)
# Option C: Combine into a multi-class crop parameters table
crop_params <- wapor_combine_crop_params(custom_crop, custom_maize)
library(Rwapor)
config <- list(
period = c("2023-10-01", "2024-05-31"),
ref_year = 1970,
aeti_var = "L2-AETI-D",
ret_var = "L1-RET-D",
precip_var = "L1-PCP-D",
npp_var = "L2-NPP-D",
t_var = "L2-T-D",
data_source = "local",
folder = "wapor_data",
area_weighted = TRUE, # Exact latitude-aware pixel weighting
indicators = c("agg_aeti", "agg_t", "etc", "adequacy_etc", "peff", "cwp_bwp", "beneficial_fraction")
)
# Crop classification mask
rasters <- list(crop_mask = terra::rast("crop_mask.tif"))
# Run seasonal analysis engine
results <- wapor_run_seasonal_analysis(
config = config,
crop_params = crop_params,
rasters = rasters
)
# Export all seasonal rasters, monthly aggregations, and CSV summaries
wapor_export_analysis_outputs(
results = results,
folder = "outputs/Winter_2023",
indicators = config$indicators,
season_label = "Winter_2023"
)
Identify spatial water stress using temporal $Z$-scores and statistical classification:
library(Rwapor)
library(terra)
# Multi-year seasonal AETI stack
aeti_stack <- c(rast("aeti_2021.tif"), rast("aeti_2022.tif"), rast("aeti_2023.tif"))
# Compute pixel-wise temporal Z-score
z_score <- wapor_calc_zscore(aeti_stack)
# Classify 2023 season into deficit / normal / surplus hotspots (+/- 1.96 = 95% CI)
hotspots_2023 <- wapor_calc_spatial_hotspots(z_score[[3]], low = -1.96, high = 1.96)
# Plot classified deficit/surplus map
plot(hotspots_2023, col = c("#d7191c", "#fdae61", "#ffffbf", "#a6d96a", "#1a9641"))
Full, applied case studies live in their own vignettes so this page stays short — each one builds a crop mask, defines crop coefficients, and runs the complete indicator chain through to Crop/Biomass Water Productivity.
Build a wheat-only mask from a crop-type raster, define wheat's $K_c$ profile, and run one season's start-to-end analysis (AETI → ETc → Adequacy → CWP/BWP):
wheat_mask <- terra::classify(crop_type, rcl = matrix(c(11, 1), ncol = 2), othersNA = TRUE)
wheat_params <- wapor_custom_crop(base_crop = "Winter Wheat", class_value = 1L, crop_name = "Irrigated Winter Wheat")
config$period <- c("2023-10-15", "2024-05-31") # this season's start/end
wheat_season <- wapor_run_seasonal_analysis(config, wheat_params, rasters = list(crop_mask = wheat_mask))
Full walkthrough: vignette("wheat-water-productivity") — includes
building the mask from either a classified raster or a field-boundary
vector, and exporting CWP/BWP rasters and summary tables.
Same wheat mask and crop parameters, applied across several years by passing a named list of season start/end pairs instead of one:
config$period <- list(
"Wheat_Winter2021" = c("2020-10-15", "2021-05-31"),
"Wheat_Winter2022" = c("2021-10-15", "2022-05-31"),
"Wheat_Winter2023" = c("2022-10-15", "2023-05-31")
)
wheat_all_seasons <- wapor_run_seasonal_analysis(config, wheat_params, rasters = list(crop_mask = wheat_mask))
Full walkthrough: vignette("wheat-water-productivity") — covers the
same multi-season pattern plus year-over-year CWP comparison.
| Indicator | Code | Description | Formula / Method |
|---|---|---|---|
| Seasonal AETI | agg_aeti | Total seasonal actual evapotranspiration | $\sum (AETI_i \times w_i \times \text{mult}_i)$ (mm) |
| Seasonal RET | agg_ret | Total seasonal reference evapotranspiration | $\sum (RET_i \times w_i \times \text{mult}_i)$ (mm) |
| Crop ET | etc | Potential crop evapotranspiration | $ET_c = RET \times K_c(\text{stage})$ |
| Water Adequacy | adequacy_etc | Evapotranspiration deficit ratio | $\text{Adequacy} = AETI / ET_c$ |
| Upper Adequacy | adequacy_p95 | Adequacy relative to 95th percentile target | $\text{Adequacy}{95} = AETI / P{95}(AETI)$ |
| Beneficial Fraction | beneficial_fraction | Ratio of transpiration to total AETI | $BF = \text{Seasonal } T / \text{Seasonal } AETI$ |
| Effective Precipitation | peff | Usable rainfall for crop consumption | USDA Soil Conservation Service monthly method |
| Green / Blue Water | green_water, blue_water | Partitioning of water consumption | Green: $\min(AETI, P_{\text{eff}})$, Blue: $\max(0, AETI - P_{\text{eff}})$ |
| Biomass Water Productivity | cwp_bwp | Biomass produced per unit of water consumed | $BWP = \text{AGBP } (\text{kg/ha}) / (AETI \times 10)$ ($\text{kg/m}^3$) |
| Crop Water Productivity | cwp_bwp | Crop yield produced per unit of water consumed | $CWP = \text{Yield } (\text{kg/ha}) / (AETI \times 10)$ ($\text{kg/m}^3$) |
| Spatial Uniformity | cv_aeti, theil_aeti | Spatial variation & inequality across field/scheme | Coefficient of Variation ($CV$) & Theil Disparity Index |
| Level | Spatial Resolution | Coverage | Key Variables |
|---|---|---|---|
| Level 1 | ~300 m | Global | L1-AETI-D, L1-E-D, L1-I-D, L1-NPP-D, L1-T-D |
| Level 1 | ~5 km | Global | L1-PCP-D |
| Level 1 | ~30 km | Global | L1-RET-D |
| Level 2 | ~100 m | Africa & Near East | L2-AETI-D, L2-E-D, L2-I-D, L2-NPP-D, L2-T-D, L2-GBWP-A, L2-NBWP-A |
| Level 3 | ~20 m | 30+ Irrigation Schemes | L3-AETI-D, L3-E-D, L3-I-D, L3-NPP-D, L3-T-D (e.g. Awash, Bekaa, Gezira, Nile) |
| AgERA5 | 0.1° (~10 km) | Global | AGERA5-ET0-E, AGERA5-TMIN-E, AGERA5-TMAX-E, AGERA5-PRECIP-E |
L1-PCP-D(precipitation) andL1-RET-D(reference evapotranspiration) are auxiliary meteorological inputs sourced from coarser gridded/reanalysis products, not the 300 m PROBA-V/MODIS-derived imagery used for the other Level 1 evapotranspiration and productivity variables. Resolutions above are the variables' native source resolution, as recorded in the package's own metadata (inst/metadata/wapor_L1.json), and apply across all temporal resolutions of a variable — dekadal (-D), monthly (-M), and annual (-A) products share the same native spatial resolution as their-E/-Dcounterpart shown here (e.g.L1-AETI-MandL1-AETI-Aare still ~300 m,L1-PCP-MandL1-PCP-Aare still ~5 km).
Explore available variables inside R:
?WAPOR3_VARS # WaPOR v3 metadata table
?AGERA5_VARS # AgERA5 variables metadata table
?L3_REGIONS # Sub-national Level 3 regions
Browse locally after installation:
browseVignettes("Rwapor")
# or open a specific one:
vignette("getting-started", package = "Rwapor")
vignette("shiny-dashboard", package = "Rwapor")
vignette("advanced-analysis", package = "Rwapor")
vignette("wheat-water-productivity", package = "Rwapor")
vignette("data-catalog", package = "Rwapor")
If the pkgdown site is published for this repository, the same vignettes are also available online:
?wapor_ts or ?run_wapor from the R console.If you use Rwapor in academic publications or operational water accounting projects, please cite:
@software{Rwapor,
title = {{Rwapor}: An {R} Package for Downloading and Analyzing {FAO WaPOR} Data},
author = {Mohammed, Almutaz},
year = {2024},
url = {https://github.com/almutaz9000/Rwapor},
note = {R package version 1.0.0}
}
MIT License © 2024 Almutaz Mohammed / Food and Agriculture Organization of the United Nations.