Extract climate data from a NETCDF file produced and made available by the European Climate Assessment & Dataset for a specific period and available at https://surfobs.climate.copernicus.eu/dataaccess/access_eobs.php

extract_nc_value(
  first_year = NULL,
  last_year = NULL,
  local_file = TRUE,
  file_path = NULL,
  sml_chunk = NULL,
  spatial_extent = NULL,
  clim_variable = "mean temp",
  statistic = "mean",
  grid_size = 0.25,
  ecad_v = NULL,
  write_raster = FALSE,
  out = NULL,
  outformat = "GTiff",
  return_data = TRUE,
  raw_datavals = TRUE,
  ...
)

Arguments

first_year

a numeric value defining the first year of the time period to extract, 1950 if NULL, default=NULL

last_year

a numeric value defining the last year of the time period to extract, 2014 if NULL, default=NULL

local_file

logical if the ".nc" data are available on your local disc, if FALSE, the function will download the data from ECAD data portal, default=TRUE

file_path

character string with the path to the local ".nc" file. Works only if local_file = TRUE, default=NULL

sml_chunk

a character string for specific time period to be downloaded. Chunk available are "2011-2023", "1995-2010", "1980-1994", "1965-1979", and "1950-1964", but check what's available at https://surfobs.climate.copernicus.eu/dataaccess/access_eobs_chunks.php

spatial_extent

object to define the spatial extent for the data extraction, can be an "sf", "sp" or "SpatialVector" object or a vector with 4 values defining the bounding box c(xmin, ymax, xmax, ymax). If NULL (default), the entire extent is extracted

clim_variable

a character string defining the daily climate variable to retrieve and extract; "mean temp","max temp","min temp","precipitation", "sea level pressure", "relative humidity", "global radiation", default="mean temp"

statistic

a character string defining the metric to retrieve, "mean" or "spread", where the mean is computed across 100 members of the ensemble and is provided as the "best-guess" fields. The spread is calculated as the difference between the 5th and 95th percentiles over the ensemble to provide a measure indicative of the 90% uncertainty range (see details)

grid_size

numeric, measured in degree defining the resolution of the grid, 0.25 (ca. 27 kilometres in latitude) or 0.1 (ca. 11 kilometres in latitude), default=0.25

ecad_v

ECA&D data version, default = package version.

write_raster

logical, if TRUE the output will be written in a multilayer raster file

out

character string with the filename for the output raster, if null data will be written in "climateExtract_raster.tiff".

outformat

character string with the format for the output raster, using GDAL shortname. You can use gdal(drivers=TRUE) to see what drivers are available in your installation; default is set to GEOTiff.

return_data

logical, if TRUE the data resulting from the extract will be stored in the object, if false, only the filename of the raster and the name of the layers are returned in a list, only if write_out is TRUE.

raw_datavals

If TRUE, then the actual raw data values from the file are returned with no conversion to NA (if equal to the missing value/fill value) or scale/offset applied. Default is TRUE. This reduce the size of the object to manipulate.

...

additional arguments for for writing files, see writeRaster

Value

If 'write_raster' is TRUE, return a list with the path to raster Brick written to the disk and the name of the layers in the object (date). If 'return_data' = TRUE, a list of object is returned, with the variable_name, an 3D array with the value extracted, a vector with the longitude, a vector with latitude and a vector with date extracted.

Details

By default, this function asks to select the ".nc" file from your local disc, but this can be changed by setting the argument 'local_file' to FALSE. When local_file is false, the nc file with data will be downloaded from the ECAD. If first_year and last_year are not provided, the function extract the full data set. Smaller chunks of about 15 years of the most recent version of the E-OBS dataset can be specified for download can be specified directly with the argument "sm_chunk" (period available are 2011-2023, 1995-2010, 1980-1994, 1965-1979, 1950-1964). For more details about the mean and the spread metric see Cornes et al. (2018) and the guidance on how to use ensemble datasets available from http://surfobs.climate.copernicus.eu/userguidance/use_ensembles.php

Author

Reto Schmucki