| Title: | Identify and Characterize Drought Events from Drought Index Time Series |
|---|---|
| Description: | Detects, describes, and analyzes drought events from time series of drought indices, such as the Standardized Precipitation-Evapotranspiration Index (SPEI). Identifies drought episodes based on threshold values and calculates their duration, intensity, severity, and peak month. Includes utilities for summarizing and visualizing drought dynamics over time. The Standardized Precipitation-Evapotranspiration Index is described in Vicente-Serrano et al. (2010) <doi:10.1175/2009JCLI2909.1>. |
| Authors: | Antonio Jesus Perez-Luque [cre, aut, cph] (ORCID: <https://orcid.org/0000-0002-1747-0469>) |
| Maintainer: | Antonio Jesus Perez-Luque <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-30 21:32:13 UTC |
| Source: | https://github.com/cran/droughtevents |
Adds shaded polygons, vertical lines, or both to a ggplot object to highlight drought events,
based on a drought assessment summary (as returned by droughts()). Optionally,
labels or points can be added to indicate drought severity.
add_drought_events( p, drought_assessment, which_events = c("all", "top"), metric = c("duration", "severity", "intensity", "lowest_index"), top_n = 5, type = c("line", "polygon", "both"), line_col = "black", line_type = "dashed", pol_fill = "gray70", pol_alpha = 0.5, show_severity = FALSE )add_drought_events( p, drought_assessment, which_events = c("all", "top"), metric = c("duration", "severity", "intensity", "lowest_index"), top_n = 5, type = c("line", "polygon", "both"), line_col = "black", line_type = "dashed", pol_fill = "gray70", pol_alpha = 0.5, show_severity = FALSE )
p |
A |
drought_assessment |
A data frame with columns |
which_events |
Display |
metric |
If |
top_n |
Number of top events to display when |
type |
Type of marker to display: |
line_col |
Color of vertical line (if used). |
line_type |
Line type of vertical line (e.g. |
pol_fill |
Fill color of polygon (if used). |
pol_alpha |
Transparency of polygon fill. |
show_severity |
Logical. If |
A modified ggplot object.
data(spei_granada) result <- droughts(spei_granada, vname = "spei12", threshold = -1.28) p <- plot_drought_ts(spei_granada, vname = "spei12") add_drought_events( p, drought_assessment = result$drought_assessment, which_events = "top", metric = "severity", top_n = 3, type = "both", show_severity = TRUE )data(spei_granada) result <- droughts(spei_granada, vname = "spei12", threshold = -1.28) p <- plot_drought_ts(spei_granada, vname = "spei12") add_drought_events( p, drought_assessment = result$drought_assessment, which_events = "top", metric = "severity", top_n = 3, type = "both", show_severity = TRUE )
Identifies drought events in a time series when a given index (e.g., SPEI) falls below a specified threshold for at least two consecutive months. Returns the processed dataset, the detected drought events, and a summary of their characteristics.
droughts(df, vname, threshold, min_duration = 2)droughts(df, vname, threshold, min_duration = 2)
df |
A
|
vname |
A string indicating the name of the numeric column to be evaluated (e.g., |
threshold |
A numeric threshold below which values are considered part of a drought event. |
min_duration |
Minimum number of consecutive months below |
A named list with three elements:
data: the original data frame with drought flags and durations.
drought_events: only the rows that are part of drought events (duration >= min_duration).
drought_assessment: summary of each event, including duration, intensity, severity, and timing.
data(spei_granada) # Detect droughts in the SPEI-12 time series with a threshold of -1.28 droughts_result <- droughts(spei_granada, vname = "spei12", threshold = -1.28)data(spei_granada) # Detect droughts in the SPEI-12 time series with a threshold of -1.28 droughts_result <- droughts(spei_granada, vname = "spei12", threshold = -1.28)
Creates a bar plot of a drought-related time series (e.g., SPEI or SPI), where values above and below zero are colored differently. Optionally, the time series can be aggregated and displayed by year.
plot_drought_ts( df, vname, title = NULL, date_col = "date", pos_color = "blue", neg_color = "red", zero_line_color = "black", zero_line_linetype = "solid", by_year = FALSE, y_axis_title = NULL )plot_drought_ts( df, vname, title = NULL, date_col = "date", pos_color = "blue", neg_color = "red", zero_line_color = "black", zero_line_linetype = "solid", by_year = FALSE, y_axis_title = NULL )
df |
A |
vname |
A string. Name of the numeric column representing the drought index. |
title |
An optional character string for the plot title. |
date_col |
A string. Name of the column containing date information (default is |
pos_color |
Color used for positive values (default is |
neg_color |
Color used for negative values (default is |
zero_line_color |
Color of the horizontal line at zero (default is |
zero_line_linetype |
Line type for the horizontal zero line (default is |
by_year |
Logical. If |
y_axis_title |
Optional label for the y-axis. If |
This plot is useful for visualizing the temporal dynamics of drought indices,
highlighting positive (wet) and negative (dry) periods. When by_year = TRUE,
the function averages the index per year and plots one bar per year.
A ggplot object representing the drought index time series as a bar plot.
data(spei_granada) plot_drought_ts(spei_granada, vname = "spei12", title = "SPEI-12 Time Series") plot_drought_ts(spei_granada, vname = "spei12", title = "SPEI-12 Annual Mean", by_year = TRUE)data(spei_granada) plot_drought_ts(spei_granada, vname = "spei12", title = "SPEI-12 Time Series") plot_drought_ts(spei_granada, vname = "spei12", title = "SPEI-12 Annual Mean", by_year = TRUE)
Standardised Precipitation-Evapotranspiration Index (SPEI) time series for Granada, Spain (coordinates -3.75, 37.25), at four different time scales (6, 12, 24, and 48 months). SPEI is a multi-scalar drought index that combines precipitation and evapotranspiration data; negative values indicate drier-than-average conditions, positive values indicate wetter-than-average conditions.
Note that the longer time scales (spei12, spei24, spei48) require
that many months of prior data to be computed, so they contain NaN
values at the start of the series.
spei_granadaspei_granada
A data frame (tibble) with 1,483 rows and 5 columns:
Date of the observation (class Date), monthly from
1901-06-16 to 2024-12-16.
SPEI at the 6-month time scale.
SPEI at the 12-month time scale. NaN for the first
months of the series.
SPEI at the 24-month time scale. NaN for the first
months of the series.
SPEI at the 48-month time scale. NaN for the first
months of the series.
A tibble with 1,483 rows and 5 columns, as described in @format.
https://spei.csic.es/spei_database/
Vicente-Serrano, S.M., Beguería, S., López-Moreno, J.I. (2010). A Multi-scalar Drought Index Sensitive to Global Warming: The Standardized Precipitation Evapotranspiration Index. Journal of Climate, 23(7), 1696-1718. doi:10.1175/2009JCLI2909.1
data(spei_granada) tail(spei_granada) # Detect drought events using the 12-month SPEI droughts(spei_granada, vname = "spei12", threshold = -1.28)data(spei_granada) tail(spei_granada) # Detect drought events using the 12-month SPEI droughts(spei_granada, vname = "spei12", threshold = -1.28)