Pointwise interpolate irregular gridded data
interpp.RdThis function implements bivariate interpolation onto a set of points for irregularly spaced input data.
This function is meant for backward compatibility to package
akima, please use interp with its output
argument set to "points" now. Especially newer options to the underlying
algorithm are only available there.
Usage
interpp(x, y = NULL, z, xo, yo = NULL, linear = TRUE,
extrap = FALSE, duplicate = "error", dupfun = NULL,
deltri = "shull")Arguments
- x
vector of x-coordinates of data points or a
SpatialPointsDataFrameobject. Missing values are not accepted.- y
vector of y-coordinates of data points. Missing values are not accepted.
If left as NULL indicates that
xshould be aSpatialPointsDataFrameandznames the variable of interest in this dataframe.- z
vector of z-coordinates of data points or a character variable naming the variable of interest in the
SpatialPointsDataFramex.Missing values are not accepted.
x,y, andzmust be the same length (execpt ifxis aSpatialPointsDataFrame) and may contain no fewer than four points. The points ofxandycannot be collinear, i.e, they cannot fall on the same line (two vectorsxandysuch thaty = ax + bfor somea,bwill not be accepted).- xo
vector of x-coordinates of points at which to evaluate the interpolating function. If
xis aSpatialPointsDataFramethis has also to be aSpatialPointsDataFrame.- yo
vector of y-coordinates of points at which to evaluate the interpolating function.
If operating on
SpatialPointsDataFrames this is left asNULL- linear
logical – indicating wether linear or spline interpolation should be used.
- extrap
logical flag: should extrapolation be used outside of the convex hull determined by the data points? Not possible for linear interpolation.
- duplicate
indicates how to handle duplicate data points. Possible values are
"error"- produces an error message,"strip"- remove duplicate z values,"mean","median","user"- calculate mean , median or user defined function of duplicate z values.- dupfun
this function is applied to duplicate points if
duplicate="user"- deltri
triangulation method used, this argument will later be moved into a control set together with others related to the spline interpolation!
Value
a list with 3 components:
- x,y
If
output="grid": vectors of \(x\)- and \(y\)-coordinates of output grid, the same as the input argumentxo, oryo, if present. Otherwise, their default, a vector 40 points evenly spaced over the range of the inputxandy.If
output="points": vectors of \(x\)- and \(y\)-coordinates of output points as given byxoandyo.- z
If
output="grid": matrix of fitted \(z\)-values. The valuez[i,j]is computed at the point \((xo[i], yo[j])\).zhas dimensionslength(xo)timeslength(yo).If
output="points": a vector with the calculated z values for the output points as given byxoandyo.If the input was a
SpatialPointsDataFrameaSpatialPixelssDataFrameis returned foroutput="grid"and aSpatialPointsDataFrameforoutput="points".
References
Moebius, A. F. (1827) Der barymetrische Calcul. Verlag v. Johann Ambrosius Barth, Leipzig, https://books.google.at/books?id=eFPluv_UqFEC&hl=de&pg=PR1#v=onepage&q&f=false
Franke, R., (1979). A critical comparison of some methods for interpolation of scattered data. Tech. Rep. NPS-53-79-003, Dept. of Mathematics, Naval Postgraduate School, Monterey, Calif.
Author
Albrecht Gebhardt <[email protected]>, Roger Bivand <[email protected]>
Note
This is only a call wrapper meant for backward compatibility, see
interp for more details!
Examples
### Use all datasets from Franke, 1979:
### calculate z at shifted original locations.
data(franke)
for(i in 1:5)
for(j in 1:3){
FR <- franke.data(i,j,franke)
IL <- with(FR, interpp(x,y,z,x+0.1,y+0.1,linear=TRUE))
str(IL)
}
#> List of 3
#> $ x: num [1:100] 0.123 0.122 0.102 0.14 0.132 ...
#> $ y: num [1:100] 0.069 0.358 0.594 0.799 1.011 ...
#> $ z: num [1:100] 0.96 0.837 0.41 0.299 NA ...
#> List of 3
#> $ x: num [1:33] 0.1 0.1 0.1 0.6 0.2 0.25 0.4 0.2 0.15 1.1 ...
#> $ y: num [1:33] 0.1 1.1 0.6 1.1 0.25 0.4 0.45 0.85 0.55 0.1 ...
#> $ z: num [1:33] 0.986 NA 0.468 NA 1.125 ...
#> List of 3
#> $ x: num [1:25] 0.238 1.012 0.812 0.325 0.05 ...
#> $ y: num [1:25] 1.075 1.088 0.862 0.938 0.512 ...
#> $ z: num [1:25] NA NA 0.0872 0.2133 0.4689 ...
#> List of 3
#> $ x: num [1:100] 0.123 0.122 0.102 0.14 0.132 ...
#> $ y: num [1:100] 0.069 0.358 0.594 0.799 1.011 ...
#> $ z: num [1:100] 0.0647 0.2163 0.2222 0.2222 NA ...
#> List of 3
#> $ x: num [1:33] 0.1 0.1 0.1 0.6 0.2 0.25 0.4 0.2 0.15 1.1 ...
#> $ y: num [1:33] 0.1 1.1 0.6 1.1 0.25 0.4 0.45 0.85 0.55 0.1 ...
#> $ z: num [1:33] 0.115 NA 0.216 NA 0.136 ...
#> List of 3
#> $ x: num [1:25] 0.238 1.012 0.812 0.325 0.05 ...
#> $ y: num [1:25] 1.075 1.088 0.862 0.938 0.512 ...
#> $ z: num [1:25] NA NA 0.163 0.222 0.222 ...
#> List of 3
#> $ x: num [1:100] 0.123 0.122 0.102 0.14 0.132 ...
#> $ y: num [1:100] 0.069 0.358 0.594 0.799 1.011 ...
#> $ z: num [1:100] 0.2593 0.1059 0.0324 0.1079 NA ...
#> List of 3
#> $ x: num [1:33] 0.1 0.1 0.1 0.6 0.2 0.25 0.4 0.2 0.15 1.1 ...
#> $ y: num [1:33] 0.1 1.1 0.6 1.1 0.25 0.4 0.45 0.85 0.55 0.1 ...
#> $ z: num [1:33] 0.2311 NA 0.0701 NA 0.2118 ...
#> List of 3
#> $ x: num [1:25] 0.238 1.012 0.812 0.325 0.05 ...
#> $ y: num [1:25] 1.075 1.088 0.862 0.938 0.512 ...
#> $ z: num [1:25] NA NA 0.0612 0.2286 0.0415 ...
#> List of 3
#> $ x: num [1:100] 0.123 0.122 0.102 0.14 0.132 ...
#> $ y: num [1:100] 0.069 0.358 0.594 0.799 1.011 ...
#> $ z: num [1:100] 0.0632 0.1457 0.1429 0.1113 NA ...
#> List of 3
#> $ x: num [1:33] 0.1 0.1 0.1 0.6 0.2 0.25 0.4 0.2 0.15 1.1 ...
#> $ y: num [1:33] 0.1 1.1 0.6 1.1 0.25 0.4 0.45 0.85 0.55 0.1 ...
#> $ z: num [1:33] 0.07 NA 0.124 NA 0.15 ...
#> List of 3
#> $ x: num [1:25] 0.238 1.012 0.812 0.325 0.05 ...
#> $ y: num [1:25] 1.075 1.088 0.862 0.938 0.512 ...
#> $ z: num [1:25] NA NA 0.117 0.1 0.121 ...
#> List of 3
#> $ x: num [1:100] 0.123 0.122 0.102 0.14 0.132 ...
#> $ y: num [1:100] 0.069 0.358 0.594 0.799 1.011 ...
#> $ z: num [1:100] 0.00044 0.01871 0.01459 0.00541 NA ...
#> List of 3
#> $ x: num [1:33] 0.1 0.1 0.1 0.6 0.2 0.25 0.4 0.2 0.15 1.1 ...
#> $ y: num [1:33] 0.1 1.1 0.6 1.1 0.25 0.4 0.45 0.85 0.55 0.1 ...
#> $ z: num [1:33] 0.00108 NA 0.01274 NA 0.0138 ...
#> List of 3
#> $ x: num [1:25] 0.238 1.012 0.812 0.325 0.05 ...
#> $ y: num [1:25] 1.075 1.088 0.862 0.938 0.512 ...
#> $ z: num [1:25] NA NA 0.01716 0.00391 0.01746 ...