Smoothing of “spatial” data

可紊 提交于 2019-12-04 11:55:00
metasequoia

Check out @Paul Heimstra's answer here. They suggest thin plate spline interpolation from the fields package. If kriging is right for you, the package automap may be useful.

If you're concerned with the interpolation of geographic values, it's worth mentioning DG Rossiter's online/free course on Geostatistics and Open-source statistical computing.

Thin plate splines, or the Tps() function, from the fields package is a your ticket. The model results must then be placed into the predictSurface() function from the same package to generate smoothed spatial data. Just a few lines of code is all you need:

test.spline <- Tps(data.frame(x,y), z)
new.grid <- predictSurface(test.spline, nx = 200, ny = 200)
image(new.grid)

The nature of the data will define how fine a grid is appropriate. You control this with nx and ny arguments in predictSurface(). In this example, increased grid resolution has no impact. With real spatial data, smoothing with a high-res surface can be dramatic. Check function help for more details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!