[R-sig-Geo] trend surface with gstat

Roger Bivand Roger.Bivand at nhh.no
Wed Apr 11 12:24:56 CEST 2007


On Wed, 11 Apr 2007, temiz wrote:

> hello
> 
> I wonder  how I can create  trend surface with gstat?
> 
> can you supply an example ?

?gstat
x <- gstat(..., degree=2)

predict(x, newdata=...)

for a quadratic surface.

library(gstat)
data(meuse)
coordinates(meuse) <- c("x", "y")
data(meuse.grid)
coordinates(meuse.grid) <- c("x", "y")
gridded(meuse.grid) <- TRUE
x <- gstat(formula=zinc ~ 1, data=meuse, degree=2)
res <- predict(x, newdata=meuse.grid)
spplot(res, "var1.pred")

Roger

> 
> regards
> 
> 
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list