IDW: Inverse Distance Weighting

InverseDistanceWeightingR Documentation

Inverse Distance Weighting

Description

Interpolate values in n-th dimensional space.

Usage

IDW(x0, u0, x, p = 2, na.rm = FALSE)

Arguments

x0, x

numeric matrix of coordinates. Each row is a new coordinate, and each column is a new dimension.

u0

numeric or complex vector; known values corresponding to the coordinates of x0.

p

a positive number; the influence of closer points.

na.rm

logical. Should missing values (including NaN) in u0 and rows containing missing values in x0 be removed?

Details

x0 and x must have the same number of dimensions.

Value

a numeric or complex vector, equal in length to the number of rows of x.

Examples

x0 <- c(0, 1, 4, 5)
u0 <- c(1, 2, 2, 1)
x <- seq.int(-4, 9, length.out = 1001)
u <- IDW(x0, u0, x)
graphics::plot(
    panel.first = graphics::grid(col = "gray69"),
    x, u, type = "l", col = "blue", lwd = 2
)
graphics::points(x0, u0, pch = 16, cex = 1.5)

ArcadeAntics/essentials documentation built on Nov. 7, 2024, 4:33 p.m.