In this report, I analyze daily precipitation data from a weather station in Czechia (P3PRIB01) located in Přibyslav near Havlíčkův Brod, provided by the Czech Hydrometeorological Institute (CHMI). The data covers multiple years and requires cleaning and reshaping before statistical analysis. The goal is to identify precipitation trends that can help inform water governance and climate adaptation strategies.
Here, I import the raw Excel data from CHMI, which contains daily precipitation values arranged in a wide format with years, months, and days. I skip the initial header rows and rename columns for clarity. Then, I transform the data from a wide to a long format, making it easier to work with dates and precipitation values.
# Read the file
file_path <- "C:/Users/mmere/Downloads/archive/P3PRIB01.xlsx"
# Read precipitation sheet skipping metadata rows
precip_raw <- read_excel(file_path, sheet = "úhrn srážek", skip = 3)
# Rename columns for easier handling
setnames(precip_raw, c("year", "month", as.character(1:(ncol(precip_raw)-2))))
# Convert to data.table
precip_dt <- as.data.table(precip_raw)
# Melt from wide to long format
precip_long <- melt(precip_dt, id.vars = c("year", "month"),
variable.name = "day", value.name = "precip")
# Convert types
precip_long[, year := as.integer(year)]
precip_long[, month := as.integer(month)]
precip_long[, day := as.integer(as.character(day))]
precip_long[, precip := as.numeric(precip)]
# Create Date column and remove invalid dates and missing values
precip_long[, date := as.Date(paste(year, month, day, sep = "-"), format = "%Y-%m-%d")]
precip_clean <- precip_long[!is.na(date) & !is.na(precip)]
head(precip_clean)
## year month day precip date
## <int> <int> <int> <num> <Date>
## 1: 1961 1 1 0.9 1961-01-01
## 2: 1961 2 1 0.4 1961-02-01
## 3: 1961 3 1 3.4 1961-03-01
## 4: 1961 4 1 1.8 1961-04-01
## 5: 1961 5 1 9.7 1961-05-01
## 6: 1961 6 1 0.0 1961-06-01
This chart shows total monthly precipitation for each year. It highlights seasonal patterns and reveals wetter and dryer periods. For instance, Year 2002 was exceptionally wet. Understanding monthly dynamics is essential for water system planning.
monthly_precip <- precip_clean[, .(total_precip = sum(precip)), by = .(year, month)]
monthly_precip[, date := as.Date(paste(year, month, 1, sep = "-"))]
ggplot(monthly_precip, aes(x = date, y = total_precip)) +
geom_line(color = "blue") +
labs(title = "Monthly Total Precipitation Over Time",
x = "Date",
y = "Total Precipitation (mm)") +
theme_minimal()
We display the total annual precipitation along with a fitted linear trend. The slope indicates whether precipitation is increasing or decreasing over time. A statistically significant trend could signal climate-driven changes impacting long-term water security.
avg_monthly <- precip_clean[, .(avg_precip = mean(precip)), by = month]
ggplot(avg_monthly, aes(x = month, y = avg_precip)) +
geom_line(color = "blue") +
geom_point(color = "red") +
labs(title = "Average Daily Precipitation by Month (All Years)",
x = "Month",
y = "Average Precipitation (mm)") +
scale_x_continuous(breaks = 1:12) +
theme_minimal()
This simple linear regression estimates how annual precipitation changes over time. A significant slope suggests a trend that could be due to climate variability or change.
# Summarize total precipitation by year
annual_precip <- precip_clean[, .(total_precip = sum(precip, na.rm = TRUE)), by = year]
# Plot again to visualize
ggplot(annual_precip, aes(x = year, y = total_precip)) +
geom_line(color = "steelblue") +
geom_smooth(method = "lm", color = "darkred", se = TRUE) +
labs(title = "Annual Total Precipitation with Trend Line",
x = "Year", y = "Total Precipitation (mm)")
## `geom_smooth()` using formula = 'y ~ x'
In this section, we aggregate daily precipitation data into annual totals to observe long-term trends. This analysis helps identify potential changes in climate patterns over the decades. By examining yearly totals, we can assess whether precipitation levels are increasing, decreasing, or remaining stable. This is especially important for understanding climate variability and its implications for water resource management in the Czech Republic.
lm_model <- lm(total_precip ~ year, data = annual_precip)
summary(lm_model)
##
## Call:
## lm(formula = total_precip ~ year, data = annual_precip)
##
## Residuals:
## Min 1Q Median 3Q Max
## -205.12 -76.77 3.55 65.23 190.56
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2241.8706 1364.7935 1.643 0.106
## year -0.7891 0.6853 -1.151 0.254
##
## Residual standard error: 96.56 on 60 degrees of freedom
## Multiple R-squared: 0.02162, Adjusted R-squared: 0.005314
## F-statistic: 1.326 on 1 and 60 DF, p-value: 0.2541
# Plot the regression line over the annual total precipitation
ggplot(annual_precip, aes(x = year, y = total_precip)) +
geom_point(color = "steelblue", size = 2) +
geom_smooth(method = "lm", se = TRUE, color = "darkred", linetype = "dashed") +
labs(title = "Regression of Annual Total Precipitation",
x = "Year",
y = "Total Precipitation (mm)") +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
This analysis used real daily precipitation data from the Czech Hydrometeorological Institute (CHMI) to explore long-term precipitation patterns for the P3PRIB01 station. We successfully cleaned and reshaped the raw data, allowing for detailed daily and monthly precipitation assessments over multiple decades.
The visualizations highlight seasonal variability and general trends in precipitation, which are important for understanding water availability and informing water governance strategies in Czechia. Using authentic data strengthens the reliability of the analysis and makes it relevant for climate adaptation and resource management discussions.
Further analyses could include more stations, trend tests, or integrating other climatic variables to provide a comprehensive picture of climate impacts on water resources.