interpolate_variable: Interpolate variable, mask to extent, write raters to file.

View source: R/interpolate_variable.R

interpolate_variableR Documentation

Interpolate variable, mask to extent, write raters to file.

Description

This function runs interpolations, raster masking using akgfmaps::rasterize_and_mask(), and coldpool::cpa_from_raster to calculate cold pool area using

Usage

interpolate_variable(
  dat,
  dat.year,
  var.col,
  lat.col,
  lon.col,
  in.crs = "EPSG:4326",
  interpolation.crs,
  cell.resolution,
  interpolation.extent = NULL,
  nm = Inf,
  pre = NA,
  select.region = "sebs",
  methods = c("NN", "IDW", "IDW4", "Exp", "Sph", "Bes", "Gau", "Cir", "Mat", "Ste",
    "Tps"),
  bbox = NULL,
  return_raster = FALSE,
  outputfilefun = 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.

pre

Prefix for file names in output (in development.)

select.region

Region for interpolation as a character string OR an sf object. Character options = "ebs", "sebs", "nbs". If select.region is an sf object, must provide bbox.

methods

To use as a character vector. Valid choices: "NN", "IDW", "IDW4", "Exp", "Sph", "Bes", "Gau", "Cir", "Mat", "Ste", "Tps"

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.

outputfilefun

Function of the form f(mask, year, method, var) that returns a string holding the full path name where the output raster should be stored. If not included, default is [coldpool_dir]/output/raster/[mask]/[var]/[mask]_[method]_[year]_[var].tif

return.raster

Should a raster be returned?

Value

Returns a data frame containing cold pool areas estimated by interpolation methods, for cutoffs at zero degrees and two degrees C. If argument write.to.file = TRUE, also writes a GeoTIFF raster to output directory.


afsc-gap-products/coldpool documentation built on Feb. 25, 2024, 9:44 p.m.