interpolate_data: Interpolation process for spatial data

View source: R/tidy_interpolation.R

interpolate_dataR Documentation

Interpolation process for spatial data

Description

Interpolate spatial data to obtain downscaled meteorologic variables

Usage

interpolate_data(
  spatial_data,
  interpolator,
  dates = NULL,
  variables = NULL,
  ignore_convex_hull_check = FALSE,
  verbose = getOption("meteoland_verbosity", TRUE)
)

Arguments

spatial_data

An sf or stars raster object to interpolate

interpolator

A meteoland interpolator object, as created by create_meteo_interpolator

dates

vector with dates to interpolate (must be within the interpolator date range). Default to NULL (all dates present in the interpolator object)

variables

vector with variable names to be interpolated. NULL (default), will interpolate all variables. Accepted names are "Temperature", "Precipitation", "RelativeHumidity", "Radiation" and "Wind"

ignore_convex_hull_check

Logical indicating whether errors in convex hull checks should be ignored. Checking for points to be inside the convex hull will normally raise an error if >10% of points are outside. Setting ignore_convex_hull_check = TRUE means that a warning is raised but interpolation is performed, which can be useful to users interpolating on a few points close but outside of the convex hull.

verbose

Logical indicating if the function must show messages and info. Default value checks "meteoland_verbosity" option and if not set, defaults to TRUE. It can be turned off for the function with FALSE, or session wide with options(meteoland_verbosity = FALSE)

Details

This function takes a spatial data object (sf or stars raster), an interpolator object (create_meteo_interpolator) and a vector of dates to perform the interpolation of the meteorologic variables for the spatial locations present in the spatial_data object.

Value

an object with the same class and structure as the provided spatial data with the results of the interpolation joined. In the case of spatial data being an sf, the results are added as a list-type column that can be unnested with unnest. In the case of a stars raster object, interpolation results are added as attributes (variables)

Spatial data

The spatial data provided must be of two types. (I) A sf object containing POINT for each location to interpolate or (II) a stars raster object for which the interpolation should be done. Independently of the class of spatial_data it has to have some mandatory variables, namely elevation. It should also contain aspect and slope for a better interpolation process, though this two variables are not mandatory.

Author(s)

Victor Granda García, EMF-CREAF

Miquel De Cáceres Ainsa, EMF-CREAF

Examples



# example of data to interpolate and example interpolator
data("points_to_interpolate_example")
data("meteoland_interpolator_example")

# interpolate data
res <- interpolate_data(points_to_interpolate_example, meteoland_interpolator_example)

# check result
# same class as input data
class(res)
# data
res
# results for the first location
res[["interpolated_data"]][1]
# unnest results
tidyr::unnest(res, cols = "interpolated_data")



meteoland documentation built on Aug. 21, 2023, 5:10 p.m.