Skip to contents

Extract monthly climate data (temperature and precipitation) for a given set of points or polygons within Europe.

Usage

get_monthly_climate(
  coords = NULL,
  climatic_var = "Prcp",
  period = NULL,
  output = "df",
  check_connection = FALSE
)

Arguments

coords

A matrix, data.frame, tibble::tbl_df-class, sf::sf(), or terra::SpatVector() object containing point or polygon coordinates in decimal degrees (lonlat/geographic format, EPSG 4326). Longitude must fall between -40.5 and 75.5 degrees, and latitude between 25.5 and 75.5 degrees. If coords is a matrix, it must have exactly two columns: the first containing longitude and the second containing latitude. If coords is a data.frame or a tbl_df, it must contain at least two columns called lon and lat with longitude and latitude coordinates, respectively.

climatic_var

Character. One or more climatic variables to download ("Tmax", "Tmin", "Tavg", or "Prcp"). Various elements can be concatenated in the vector.

period

Either numbers (representing years between 1950 and the latest year available), or dates in "YYYY-MM" format (to obtain data for specific months). To specify a sequence of years or months use the format 'start:end' (e.g. YYYY:YYYY or "YYYY-MM:YYYY-MM", see examples). Various elements can be concatenated in the vector (e.g. c(2000:2005, 2010:2015, 2020), c("2000-01:2000-06", "2001-01")). Use get_periods() to obtain the available data versions and years available.

output

Character. Either "df", which returns a data.frame with daily climatic values for each point or polygon, or "raster", which returns terra::SpatRaster() objects (within a list when more than one climatic variable is downloaded).

check_connection

Logical. Default is FALSE. If TRUE, checks the connection to the server before attempting to download the data.

Value

Either:

For precipitation, the function returns total (accumulated) precipitation per month. For temperature variables ("Tmin", "Tmax", "Tavg") the function returns the average (i.e. the monthly average of minimum and maximum daily temperatures, or the average monthly temperature).

References

For details on the latest version of the climatic data, see: Pucher, Christoph (2026). Description of Downscaled European Climate Data. figshare. Online resource. https://doi.org/10.6084/m9.figshare.33078053.v1

For details on version 4, see: Pucher C. 2023. Description and Evaluation of Downscaled Daily Climate Data Version 4. https://doi.org/10.6084/m9.figshare.22962671.v1

Adam Moreno, Hubert Hasenauer. 2016. Spatial downscaling of European climate data. International Journal of Climatology 36: 1444–1458.

Author

Veronica Cruz-Alonso, Francisco Rodriguez-Sanchez

Examples

if (FALSE) { # interactive()

# Coords as matrix
coords <- matrix(c(-5.36, 37.40), ncol = 2)
ex <- get_monthly_climate(coords, period = "2001-01")  # single month
ex <- get_monthly_climate(coords, period = c("2001-01", "2001-03"))  # January AND March 2001
ex <- get_monthly_climate(coords, period = "2001-01:2001-03")  # January TO March 2001
ex <- get_monthly_climate(coords, period = 2008)  # entire year
ex <- get_monthly_climate(coords, period = c(2008, 2010))  # 2008 AND 2010
ex <- get_monthly_climate(coords, period = 2008:2010)  # 2008 TO 2010

ex <- get_monthly_climate(coords, period = "2001-01", climatic_var = "Tmin")

# Coords as data.frame or tbl_df
coords <- as.data.frame(coords) #coords <- tibble::as_tibble(coords)
names(coords) <- c("lon", "lat")  # must have these columns
ex <- get_monthly_climate(coords, period = "2001-01")  # single month

# Coords as sf
coords <- sf::st_as_sf(coords, coords = c("lon", "lat"))
ex <- get_monthly_climate(coords, period = "2001-01")  # single month

# Several points
coords <- matrix(c(-5.36, 37.40, -4.05, 38.10), ncol = 2, byrow = TRUE)
ex <- get_monthly_climate(coords, period = "2001-01", output = "raster")  # raster output

# Multiple climatic variables
coords <- matrix(c(-5.36, 37.40), ncol = 2)
ex <- get_monthly_climate(coords, climatic_var = c("Tmin", "Tmax"), period = "2001-01")

## Polygons
coords <- terra::vect("POLYGON ((-5 38, -5 37.5, -4.5 37.5, -4.5 38, -5 38))")

# Return raster
ex <- get_monthly_climate(coords, period = "2001-01", output = "raster")
ex <- get_monthly_climate(coords, climatic_var = c("Tmin", "Tmax"), period = "2001-01",
output = "raster") # Multiple climatic variables

# Return dataframe for polygon
ex <- get_monthly_climate(coords, period = "2001-01")
}