interpolate_spatial: Interpolate a spatial surface from observations

View source: R/interpolate_spatial.R

interpolate_spatialR Documentation

Interpolate a spatial surface from observations

Description

Interpolates a x-y surface from a data frame of spatial observations for plotting. Currently uses the idw function.

Usage

interpolate_spatial(
  df,
  value,
  Subset = NULL,
  coords = c("lon.utm", "lat.utm"),
  station.col = "Station",
  strata.col = "From",
  name.col = NULL,
  id.cols = NULL,
  bin.method = "average",
  int.method = "idw",
  unit = NULL,
  shear = NULL,
  n.tile = 100,
  accuracy = 100
)

Arguments

df

data frame containing required information

value

Character referring to the name of the value column to be used for interpolation.

Subset

A subset argument as a character (i.e. with " ". See Examples).

coords

A vector of column names for x (longitude) and y (latitude) coordinates, respectively. It is recommended to use UTM coordinates instead of decimal degrees. See coordinates.

station.col

Character. Name of the column that specifies unique stations (i.e. spatial points). Required.

strata.col

Character. Column that specify the sampling depth.

name.col

Character. Column giving sample names. Not required.

id.cols

Character vector. Identification columns that should be preserved together with value, From, To and UTM coordinate columns

bin.method

Character giving the method for binning data, if there are several observations for each spatial point. Alternatives:

  • "none" for no binning. Requires one value per unique coordinate.

  • "average" for average values

  • "integrate" for vertical trapezoidal integration using the integrateTrapezoid function from oce package.

int.method

Character giving the method for interpolation. Currently only one option is implemented: "idw", inverse distance weighted interpolation using the idw function.

unit

The unit for value column. Not required.

shear

Map tilting. Either NULL for non-tilted maps or a shear matrix, f.ex (matrix(c(2,1.2,0,1),2,2)) to shear the interpolation. This feature works poorly.

n.tile

Number of horizontal and vertical tiles. Default is 100 resulting to 10000 tiles.

accuracy

Number to which the extent of the interpolation area should be rounded. Given in meters.

Details

The function removes missing values (NAs) from value column.

A word of warning about bin.method = "integrate": this functionality works only if samples have been taken consistently at same depths. In other cases, it is recommended to use bin.method = "average", although the user should be careful in comparing samples taken from different depths in general. The unit for integrated value is [amount]/m2, if the original value was [amount]/m3.

Value

Returns a spatInt object which is a list

Author(s)

Mikko Vihtakari

See Also

plot.spatInt for plotting; interpolate_section for

Examples

data(chlorophyll) ## load an example dataset
x <- interpolate_spatial(chlorophyll, Subset = "From <= 10", value = "Chla") ## Interpolate
plot(x) ## Plot

MikkoVihtakari/PlotSvalbard documentation built on July 12, 2022, 10:20 a.m.