Allows to extract and interpolate specific locations from grib files (see eupp_get_gridded). Requires ecCodes to be installed.

eupp_interpolate_grib(
  file,
  at,
  atname = NULL,
  bilinear = TRUE,
  wide = TRUE,
  verbose = FALSE,
  ignore_init = FALSE,
  ...
)

Arguments

file

character, name of the grib file from which the data should be extracted.

at

object of class sf or sfc containing point locations to be extracted/interpolated.

atname

NULL (default) or character length 1. Is set (and the variable exists in at) it will be appended to the returned object.

bilinear

logical, defaults to TRUE. If set to FALSE nearest neighbour interpolation is used.

wide

logical, defaults to TRUE. If TRUE the result is in a wide format, else long format.

verbose

logical, defaults to FALSE.

ignore_init

logical, defaults to FALSE; see 'Details' for more information. Only has an effect when wide = TRUE.

...

currently unused.

Details

When downloading the GRIB version 1 data sets using eupp_get_gridded() a .rds file with the grib inventory will be stored alongside with the GRIB file itself. If prsent, this .rds file will be used to retrieve the meta information (what the different fields of the GRIB file contain).

If not present, ecCodes must be installed and the index will be created by calling grib_ls -j.

It then reads the grib file using read_stars to read the data (in bands) and performs the interpolation using st_extract.

Please note that at needs a valid coordinate reference system (CRS) and must only contain POINT geometries for now.

wide: Brings the interpolated data to a wide format. Reduces the amount of meta information. See also ignore_init below when working with analysis data.

ignore_init: This option can be handy when processing analysis data. Analysis data (ERA5 reanalysis) consists of variables coming from the analysis directly (e.g., air temperature) and short-term predictions for certain parameters such as precipitation. Thus, initialization date/time and time valid differs between them resulting in a 'sparse' matrix if wide = TRUE. The argument ignore_init allows to ignore initialization date/time and forecast step to get a less (or non-)sparse data.frame. WARNING: When used with forecast data the data may no longer be unique leading to overlapping data (warnings/errors).

Author

Reto Stauffer