Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

idw.smoothing

Inverse Distance Weighted smoothing


Description

Distance weighted smoothing of a variable in a spatial point object

Usage

idw.smoothing(x, y, d, k)

Arguments

x

Object of class SpatialPointsDataFrame

y

Numeric data in x@data

d

Distance constraint

k

Maximum number of k-nearest neighbors within d

Value

A vector, same length as nrow(x), of adjusted y values

Note

Smoothing is conducted with a weighted-mean where; weights represent inverse standardized distance lags Distance-based or neighbour-based smoothing can be specified by setting the desired neighbour smoothing method to a specified value then the other parameter to the potential maximum. For example; a constraint distance, including all neighbors within 1000 (d=1000) would require k to equal all of the potential neighbors (n-1 or k=nrow(x)-1).

Examples

library(sp)
  data(meuse)                                                   
  coordinates(meuse) <- ~x+y             

# Calculate distance weighted mean on cadmium variable in meuse data   
  cadmium.idw <- idw.smoothing(meuse, 'cadmium', k=nrow(meuse), d = 1000)                
  meuse@data$cadmium.wm <- cadmium.idw

  opar <- par(no.readonly=TRUE)
    par(mfrow=c(2,1)) 
      plot(density(meuse@data$cadmium), main='Cadmium')
      plot(density(meuse@data$cadmium.wm), main='IDW Cadmium')
  par(opar)

spatialEco

Spatial Analysis and Modelling Utilities

v1.3-6
GPL-3
Authors
Jeffrey S. Evans [aut, cre], Melanie A. Murphy [ctb], Karthik Ram [ctb]
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.