[R-sig-Geo] kriging output

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon May 5 21:09:23 CEST 2008


Dave Depew wrote:
> Hi all,
> I've got a question regarding kriging outputs. I have an interpolated 
> dataset which due to the nugget effect contains some negative values 
> as the predictions. I would like to truncate these @ "0", rather than 
> having them as a negative prediction.
> I've tried something similar with the meuse data set...
>
> data(meuse.grid) coordinates(meuse.grid) = c("x", "y") 
> gridded(meuse.grid) <- TRUE
> meuse.grid[["idist"]] = 1 - meuse.grid[["dist"]]
> Somewhat arbitrary, but essentially, I'd like to set all "dist" data 
> less than 0.5 to "0", and have the rest remain as they are...
>
>
> meuse.grid[["class"]] = for(i in 1:length(meuse.grid[["dist"]])){
> if (meuse.grid[["dist"]]<0.5) {meuse.grid[["class"]]==0} else
I guess you meant an = rather than a == here
> {meuse.grid[["class"]]=meuse.grid[["dist"]]}
> }
>
> All I've managed to get is the new attribute "class" all filled with 0.
>
Try:

meuse.grid$class = meuse.grid$dist
meuse.grid$class[meuse.grid$dist < .5] = 0
plot(class~dist,meuse.grid)
--
Edzer




More information about the R-sig-Geo mailing list