Learn R Programming

spm (version 1.2.2)

idwpred: Generate spatial predictions using inverse distance weighting (IDW)

Description

This function is to make spatial predictions using inverse distance weighting.

Usage

idwpred(longlat, trainy, longlat2, nmax = 12, idp = 2, ...)

Arguments

longlat

a dataframe contains longitude and latitude of point samples.

trainy

a vector of response, must have length equal to the number of rows in longlat.

longlat2

a dataframe contains longitude and latitude of point locations (i.e., the centres of grids) to be predicted.

nmax

for a local predicting: the number of nearest observations that should be used for a prediction or simulation, where nearest is defined in terms of the space of the spatial locations. By default, 12 observations are used.

idp

numeric; specify the inverse distance weighting power.

...

other arguments passed on to gstat.

Value

A dataframe of longitude, latitude and predictions.

References

Pebesma, E.J., 2004. Multivariable geostatistics in S: the gstat package. Computers & Geosciences, 30: 683-691.

Examples

Run this code
# NOT RUN {
library(sp)
data(swmud)
data(sw)
idwpred1 <- idwpred(swmud[, c(1,2)], swmud[, 3], sw, nmax = 12, idp = 2)
names(idwpred1)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab