| Type: | Package | 
| Title: | Calculation of the Water Deficit Index (WDI) and the Evaporative Fraction (EF) on Rasters | 
| Version: | 1.0.4 | 
| Date: | 2025-10-20 | 
| Description: | Provides functions to calculate the Water Deficit Index (WDI) and the Evaporative Fraction (EF) using geospatial raster data such as fractional vegetation cover (FVC) and surface-air temperature difference (TS-TA). The package automates regression-based edge fitting and produces continuous spatial maps of surface moisture and evaporative dynamics. | 
| License: | GPL-3 | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.2 | 
| Imports: | dplyr, stats, terra | 
| Suggests: | testthat (≥ 3.0.0) | 
| NeedsCompilation: | no | 
| Packaged: | 2025-10-20 14:44:25 UTC; hamelin | 
| Author: | Gaelle Hamelin | 
| Maintainer: | Gaelle Hamelin <gaelle.hamelin@institut-agro.fr> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-10-20 18:20:02 UTC | 
Calculate the Evaporative Fraction (EF)
Description
This function calculates the EF from two rasters: fractional vegetation cover (FVC) and the surface-air temperature difference (TS-TA). It saves the resulting EF raster to the specified output path.
Usage
calculate_EF(
  FVC_path,
  TS_TA_path,
  output_path,
  n_intervals = 20,
  percentile = 0.01
)
Arguments
| FVC_path | Character. File path to the FVC raster.Must have the same CRS and extent as the TS-TA raster. | 
| TS_TA_path | Character. File path to the raster of TS-TA (surface-air temperature difference). TS and TA must have the same unit of measurement (Kelvin preferably). | 
| output_path | Character. File path where the EF raster will be saved. | 
| n_intervals | Integer. Number of intervals for splitting FVC values (default: 20). | 
| percentile | Numeric. Percentage used for identifying wet and dry edges (default: 0.01). | 
Details
- The input rasters ( - FVCand- TS-TA) must have the same CRS (Coordinate Reference System) and extent.
- If they differ, the function will attempt to reproject and resample the rasters automatically. 
Value
A raster object representing the Evaporative Fraction (EF).
Examples
# Paths to example data included in the package
library(terra)
FVC_raster <- rast(system.file("extdata", "FVC_reduced.tif", package = "wdiEF"))
TS_TA_raster <- rast(system.file("extdata", "TS_TA_reduced.tif", package = "wdiEF"))
# Output path (temporary file for example purposes)
output_path <- tempfile(fileext = ".tif")
# Run the function
calculate_EF(
  FVC_path = FVC_raster,
  TS_TA_path = TS_TA_raster,
  output_path = output_path,
  n_intervals = 20,
  percentile = 0.01
)
# Print the output path
print(output_path)
Calculate the Water Deficit Index (WDI)
Description
This function calculates the WDI from two rasters: fractional vegetation cover (FVC) and the surface-air temperature difference (TS-TA). It saves the resulting WDI raster to the specified output path.
Usage
calculate_WDI(
  FVC_path,
  TS_TA_path,
  output_path,
  n_intervals = 20,
  percentile = 0.01
)
Arguments
| FVC_path | Character. File path to the FVC raster.Must have the same CRS and extent as the TS-TA raster. | 
| TS_TA_path | Character. File path to the raster of TS-TA (surface-air temperature difference). TS and TA must have the same unit of measurement (Kelvin preferably). | 
| output_path | Character. File path where the WDI raster will be saved. | 
| n_intervals | Integer. Number of intervals for splitting FVC values (default: 20). | 
| percentile | Numeric. Percentage used for identifying wet and dry edges (default: 0.01). | 
Details
- The input rasters ( - FVCand- TS-TA) must have the same CRS (Coordinate Reference System) and extent.
- If they differ, the function will attempt to reproject and resample the rasters automatically. 
Value
A raster object representing the Water Deficit Index (WDI).
Examples
# Paths to example data included in the package
library(terra)
FVC_raster <- rast(system.file("extdata", "FVC_reduced.tif", package = "wdiEF"))
TS_TA_raster <- rast(system.file("extdata", "TS_TA_reduced.tif", package = "wdiEF"))
# Output path (temporary file for example purposes)
output_path <- tempfile(fileext = ".tif")
# Run the function
calculate_WDI(
  FVC_path = FVC_raster,
  TS_TA_path = TS_TA_raster,
  output_path = output_path,
  n_intervals = 20,
  percentile = 0.01
)
# Print the output path
print(output_path)