[R-sig-Geo] why are idw and gstat different? [SEC=UNCLASSIFIED]
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Tue Jul 8 09:34:30 CEST 2008
Jin, you specified nmax = 7 in the second call, but not in the first.
Comparing idp values is easiest when other things remain equal.
--
Edzer
Jin.Li at ga.gov.au wrote:
> Dear there,
>
> I tried to compare idw and gstat in library(gstat). I specified idp as 0.5 in
> both functions, I expected identical results, but what I got are different as
> shown for the first five samples. Please help. Thanks.
>
>
>
>
>> data(meuse)
>>
>
>
>> coordinates(meuse) = ~x+y
>>
>
>
>> data(meuse.grid)
>>
>
>
>> gridded(meuse.grid) = ~x+y
>>
>
>
>> x <- idw(zinc~1, meuse, meuse.grid, idp=0.5)
>>
>
> [inverse distance weighted interpolation]
>
>
>> as.data.frame(x)[1:5,]
>>
>
> var1.pred var1.var x y
>
> 1 482.8753 NA 181180 333740
>
> 2 487.0065 NA 181140 333700
>
> 3 483.9747 NA 181180 333700
>
> 4 481.2115 NA 181220 333700
>
> 5 494.8720 NA 181100 333660
>
>
>
>
>> data(meuse)
>>
>
>
>> data(meuse.grid)
>>
>
>
>> meuse.gstat <- gstat(id = "zinc", formula = zinc ~ 1, locations = ~ x + y,
>>
>
> + data = meuse, nmax = 7, set = list(idp = .5))
>
>
>> meuse.gstat
>>
>
> data:
>
> zinc : formula = zinc`~`1 ; data dim = 155 x 12 nmax = 7
>
> set idp = 0.5;
>
> ~x + y
>
>
>> z <- predict(meuse.gstat, meuse.grid)
>>
>
> [inverse distance weighted interpolation]
>
>
>> z[1:5,]
>>
>
> x y zinc.pred zinc.var
>
> 1 181180 333740 626.3628 NA
>
> 2 181140 333700 645.9319 NA
>
> 3 181180 333700 629.7041 NA
>
> 4 181220 333700 615.1368 NA
>
> 5 181100 333660 682.3401 NA
>
>
>
> Cheers,
>
>
>
> Jin
>
> --------------------------------------------
>
> Jin Li, PhD
>
> Spatial Modeller/
>
> Computational Statistician
>
> Marine & Coastal Environment
>
> Geoscience Australia
>
>
>
> Ph: 61 (02) 6249 9899
>
> Fax: 61 (02) 6249 9956
>
> email: jin.li at ga.gov.au <mailto:jin.li at ga.gov.au>
>
> --------------------------------------------
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics (IfGI), University of Münster, Weseler
Straße 253, 48151 Münster. Phone: +49 251 8333081 Fax: +49 251 8339763
email: edzer.pebesma at uni-muenster.de http://ifgi.uni-muenster.de/
More information about the R-sig-Geo
mailing list