[R] Extracting Krig results

Angus Carr acarr at saskforestcentre.ca
Thu Mar 4 23:43:38 CET 2004


I'm new at this, so please bear with me.

I am trying to get Krig (actually tps) results into a data frame at a 
set of points.
Frankly, all I really need is to query the Krig on a specific XY pair 
and return a result. I can carry the rest. I am using tps from the 
fields package.

Here's the code I use to create the Krig object:
=========== Snip! ===============================
dCurr <- sqlQuery(ds,"select x,y,acmi50 from public.cc_output" )
fitCurr <- Tps(dCurr[1:2],dCurr$acmi50, scale.type="unscaled")
surface(fitCurr,type="C", extrap=TRUE, main="Median ACMI, 1961-1990", 
xlab="", ylab="", levels=evens)
===============================================

Ultimately, I want a table of XY locations and their appropriate value 
from the surface. From that, I can do further statistics.

The XY locations are a regular grid, although they may not be in the 
final product. If they are a regular grid, I could use a loop to drive 
the process.

How can I do this? I am baffled by the help file, and cannot tell what 
to do.

In principle, I could read the code of the surface function and figure 
out what it does, then do the same, but I am sure I am not the only 
person who wants to do some analysis on the output of an interpolation 
function.

I want to run rpart on a data frame containing 20 variables (or so), 
some of which are interpolated from weather stations.

Thanks for any help you can provide,
Angus Carr.




More information about the R-help mailing list