data2raster: Interpolate data points to a masked raster

View source: R/data2raster.R

data2rasterR Documentation

Interpolate data points to a masked raster

Description

This function is a variant of the interpolate_variable function that allows for user-set masking polygons and choice of fitting method.

Usage

data2raster(
  dat,
  dat.year,
  var.col,
  lat.col,
  lon.col,
  in.crs = "+proj=longlat +datum=NAD83",
  interpolation.crs,
  cell.resolution,
  nm = Inf,
  select.region = "sebs",
  fittypes = c("nn", "idwnmax4", "idw", "exp", "sph", "bes", "gau", "cir", "mat", "ste",
    "tps"),
  bbox = NULL
)

Arguments

dat

Input data frame. Must include columns for latitude, longitude, and variable to be interpolated.

dat.year

Year

var.col

Character vector denoting the name of the variable column.

lat.col

Character vector indicating the name of the latitude column.

lon.col

Character vector indicating the name of the longitude column.

in.crs

Character vector (PROJ4 or WKT2/PROJ6 string) indicating the coordinate reference system for the data.

interpolation.crs

Character vector (PROJ4 or WKT2/PROJ6 string) indicating the coordinate reference system to use for the interpolation. Historically EPSG:3338

cell.resolution

Dimensions of interpolation grid cell in meters.

nm

Maximum number of cells to use for interpolation.

select.region

Region for interpolation as a character string. Can be either a string accepted by akgfmaps::get_base_layers or a simple feature polygon

fittypes

vector of strings specifying which fit algorithms to use: "nn" = nearest neighbor "idwnmax4" = inverse distance weighting with nmax=4 "idw" = inverse distance weighting "exp" = ordinary kriging w/ exponential VGM, "sph" = ordinary kriging w/ spherical VGM "bes" = ordinary kriging w/ bessel VGM "gau" = ordinary kriging w/ gaussian VGM "cir" = ordinary kriging w/ circular VGM "mat" = ordinary kriging w/ matern VGM "ste" = ordinary kriging w/ Stein's matern VGM "tps" = thin plate spline

bbox

Bounding box for the interpolated grid. Can be either a string ("sebs", "bs.south", "nebs", "ebs", "bs.north", "bs.all") corresponding to specific bounds, or a 4-element named vector with values xmin, xmax, ymin, and ymax.

Value

terra SpatRaster of interpolated data, with one layer per input fit type


afsc-gap-products/coldpool documentation built on Sept. 14, 2024, 7:40 p.m.