[R-sig-Geo] distances reported by gstat when cokriging
Tom Gottfried
tom.gottfried at tum.de
Fri Mar 16 15:57:56 CET 2012
Dear Edzer,
Am 16.03.2012 15:12, schrieb Edzer Pebesma:
> Tom, right, it is. If you specify nmax=9 for the second variable, you
> see the dist values for the second as well. They are indeed not computed
> in your case, as the selection can be copied. Apparently these things
> mattered when I wrote the code 20 years ago!
the following modified example gives "dist: 0" for "data id: 0", which
is non-colocated with the second covariate. As far as I understand the
selection cannot be copied here:
library(gstat)
data(meuse)
coordinates(meuse) <- ~x+y
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
i <- sample(1:nrow(meuse), 1)
g <- gstat(NULL, "z", zinc~1, meuse[-i,], model=varmod)
g <- gstat(g, "dist", I(dist*1000)~1, meuse[-i,])
variog.g <- variogram(g)
g <- fit.lmc(variog.g, g, vgm(100000, "Exp", 500, 1000))
varmod.dist <- g$model$dist
g <- gstat(g, "dist", I(dist*1000)~1, data=meuse.grid,
model=varmod.dist, maxdist=100)
meuse.point <- meuse[i,]
predict(g, newdata=meuse.point, debug.level=16)
> When you say, "Is there a way to get the distances for the second
> covariate?", do you mean, as R object?
Well, that would be luxurious. Currently I copy-paste those data into
Calc for further analysis. Of course I can compute the distances somehow
outside from gstat, but is there a way to get gstat doing this?
Thanks!
Tom
>
> On 03/16/2012 02:53 PM, Tom Gottfried wrote:
>> Dear list(en)ers,
>>
>> I wonder what the "dist" is, which is in the output of predict.gstat()
>> with debug.level=16. I expect it to be the distance between the
>> coordinate pair given in the same line and the prediction location. I
>> verified this for the coordinates and distances given for "data id: 0"
>> in the below example (and its true), but for "data id: 1" it's always
>> "dist: 0". Is there a way to get the distances for the second covariate?
>> I see it's simple in the example, because data are colocated, but the
>> problem arose in a case with non-colocated covariates.
>> Here's the example:
>>
>> library(gstat)
>> data(meuse)
>> coordinates(meuse)<- ~x+y
>> variog<- variogram(zinc~1, meuse)
>> varmod<- fit.variogram(variog, vgm(150000, "Exp", 1000))
>> data(meuse.grid)
>> coordinates(meuse.grid)<- ~x+y
>> g<- gstat(NULL, "z", zinc~1, meuse, model=varmod, nmax=10)
>> g<- gstat(g, "dist", I(dist*1000)~1, meuse, nmax=10)
>> variog.g<- variogram(g)
>> g<- fit.lmc(variog.g, g, vgm(100000, "Exp", 500, 1000))
>> meuse.point<- meuse.grid[sample(1:nrow(meuse.grid), 1),]
>> predict(g, newdata=meuse.point, debug.level=16)
>>
>> Thanks!
>> Tom
>>
>
--
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Alte Akademie 12
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax: ++49 (0)8161 713243
email: tom.gottfried at wzw.tum.de
http://www.wzw.tum.de/gruenland
More information about the R-sig-Geo
mailing list