# idwST: Inverse Distance Weighting (IDW) function for spatio-temporal...

Description Usage Arguments Details Value References Examples

### Description

This function performs spatio-temporal interpolation. Here idwST is in a local neighborhood. This interpolation method considers the value of a point can be obtained from the weighted sum of values of the regionalized variable of closest neighbors. The general formula for the IDW is given by:

\hat{z}_0(st)=∑_{i=1}^n λ_i z_i(st)

The expression for determining the weights is:

λ_i = \frac{d_{i0}^{-p}}{∑_{i=1}^n d_{i0}^{-p}}

The weight is controlled by a factor p with each increment of the distance, d_{i0} is the distance between the prediction position and each of the measured positions.

The expression d_{i0} can be obtained by:

d_{i0}=√{(x_{i}-x_{0})^2+(y_{i}-y_{0})^2+C\cdot (t_{i}-t_{0})^2}

x, y and t correspond to the spatio-temporal coordinates, p (factor.p) and C factors defined below.

### Usage

 1 idwST(formula, data, newdata, n.neigh, C, factor.p, progress) 

### Arguments

 formula formula that defines a detrended linear model, use z_{st}~1. data SpatialPointsDataFrame: should contain the spatio-temporal dependent variable, independent variables (statics and/or dynamics), spatial coordinates and the time as an integer or numerical variable. newdata data frame or spatial object with prediction/simulation spatio-temporal locations; should contain attribute columns with the independent variables (if present) and (if locations is a formula) the coordinates and time with names, as defined in locations where you want to generate new predictions n.neigh number of nearest observations that should be used for a idwST prediction, where nearest is defined in terms of the spatio-temporal locations C numeric; associated to time factor, we recommend using the parameter found by minimizing the root-mean-square prediction errors using cross-validation. Using idwST.cv and optimize factor.p numeric; specify the inverse distance weighting power (p is the exponent that influences the weighting or optimal smoothing parameter) progress whether a progress bar shall be printed for spatio-temporal inverse-distance weighted function; default=TRUE

### Details

idwST function generates individual spatio-temporal predictions from IDW spatio-temporal interpolation. IDW is a type of deterministic method for interpolation, the assigned values to unknown points are calculated with a weighted average of the values available at the known points.

### Value

Attributes columns contain coordinates, time, predictions, and the variance column contains NA's

### References

Li L, Losser T, Yorke C, Piltner R. (2014). Fast inverse distance weighting-based spatiotemporal interpolation: a web-based application of interpolating daily fine particulate matter PM2:5 in the contiguous U.S. using parallel programming and k-d tree. Int. J. Environ. Res. Public Health, 11: 9101-9141. [link]

### Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 # Loading Croatia data data(croatiadb) coordinates(croatiadb) <- ~x+y # prediction case: one point point <- data.frame(670863,5043464,5) names(point) <- c("x","y","t") coordinates(point) <- ~x+y idwST(MTEMP~1, data=croatiadb, newdata=point, n.neigh=60, C=1, factor.p=2) ## Not run: # prediction case: a grid of points Croatia (year 2008) data(croatia) points <- spsample(croatia, n=5000, type="regular") data(croatiadb) coordinates(croatiadb)<-~x+y GridsT <- vector(mode = "list", length = 12) for(i in 1:12){ GridsT[[i]] <- data.frame(points@coords,i) names(GridsT[[i]]) <- c("x","y","t") } idw.croatia <- data.frame(matrix(NA, ncol = 14, nrow=nrow(GridsT[[1]]))) pb <- txtProgressBar(min = 0, max = 12, char = "=", style = 3) for(i in 1:12){ coordinates(GridsT[[i]]) <- c("x", "y") idw.croatia[,i+2] <- idwST(MTEMP~1, croatiadb, newdata=GridsT[[i]], n.neigh=10, C=1, factor.p=2, progress=FALSE)[,4] setTxtProgressBar(pb, i) } close(pb) idw.croatia[,1:2] <- GridsT[[1]]@coords nam <- paste(c("ENE","FEB","MAR","ABR","MAY","JUN","JUL","AGO","SEP","OCT","NOV","DIC"), 2008,sep="") names(idw.croatia) <- c("x","y",nam) coordinates(idw.croatia) <- c("x", "y") gridded(idw.croatia) <- TRUE # show prediction map pal2 <- colorRampPalette(c("blue3", "wheat1", "red3")) p1 <- spplot(idw.croatia[,1:12], cuts=30, col.regions=pal2(35), colorkey=F, scales = list(draw =T,cex=0.6, abbreviate=TRUE,minlength=1), pch=0.3, cex.lab=0.3, cex.title=0.3, auto.key = F, main = "Earth's average temperature IDW map 2008", key.space=list(space="right", cex=0.8)) split.screen( rbind(c(0, 1,0,1), c(1,1,0,1))) split.screen(c(1,2), screen=1)-> ind screen( ind[1]) p1 screen( ind[2]) image.plot(legend.only=TRUE, legend.width=0.5, col=pal2(100), smallplot=c(0.7,0.75, 0.3,0.7), zlim=c(min(idw.croatia@data), max(idw.croatia@data)), axis.args = list(cex.axis = 0.7)) close.screen( all=TRUE) ## End(Not run) 

Search within the geosptdb package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.