The process_drought() function imports and cleans raw drought index
files returned by download_drought(), producing a harmonized output
object ready for calculate_drought():
SPEI / EDDI — returns a
SpatRasterwith one layer per time step, layer names in"<source>_<timescale>_YYYY-MM-DD"format, CRS set toEPSG:4326.USDM — returns a
SpatVector(polygon) with columnsDM(drought-monitor class, integer 0–4),date(Date), andsource("usdm"), CRSEPSG:4326.
Arguments
- source
character(1). Drought data source. One of
"spei","eddi", or"usdm". When called throughprocess_covariates(covariate = "spei")the alias is forwarded automatically.- path
character(1). Directory containing downloaded drought files (output of
download_drought()).- date
character(1 or 2). Single date or start/end dates. Format
"YYYY-MM-DD".- timescale
integer(1). Accumulation timescale in months (SPEI/EDDI only; ignored for USDM). Must match the timescale used in
download_drought(). Default1L.- extent
numeric(4) or
SpatExtent. Optional spatial crop applied before returning.NULL(default) returns full extent.- ...
Reserved for future use; currently ignored.
Note
SPEI/EDDI files are expected to follow the naming convention produced by
download_drought():spei<timescale>.ncand either legacyeddi<timescale>mn<year>.ncor currentEDDI_ETrs_<timescale>mn_<YYYYMMDD>.asc.USDM files are expected to be weekly shapefiles named
USDM_<YYYYMMDD>.shp.Layer/column naming is standardised so that
calculate_drought()can operate identically regardless of source.