The spatstat package is your friend!
http://www.spatstat.org/spatstat/
If your data is a set of events (for example, โcrime that took place (x, y)โ for many (x, y)), you can use the kernel density estimate to create your heat map. Here you can see an example:
https://github.com/drewconway/WikiLeaks_Analysis/blob/master/density.r
in particular line 72.
If your z values โโare real values โโ(this probably applies to reading your question), you can use the spartstat smooth function, which uses the Gaussian kernel to perform interpolation and returns the set of pixels that were generated by interpolating your data.
Alternatively, you can use the akima package (as recommended by spatstat ) to interpolate at the locations you specify. It uses linear or spline interpolation and seems pretty simple (although I have no experience!).
More generally, what you are trying to do is often called โKriging,โ and so you get a lot of results if you click google. See gstat and geoR .
Finally (and FTW) you can use Gaussian processes to do the same. This will give you a distribution of the possible interpolations based on your data. The kernlab package implements an implementation, although I have no idea how to use it.
Mike dewar
source share