[R-sig-Geo] comparison (1) is possible only for atomic and list types

Tom Gottfried tom.gottfried at wzw.tum.de
Thu Feb 17 13:10:24 CET 2011


Nikki,

I'm not sure whether I understood what you are trying to do, but if you just want to replace values
in a column of a SpatialGridDataFrame, sp comes with all the methods you need. Example:

library(sp)
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
meuse.grid <- as(as(meuse.grid, "SpatialPixelsDataFrame"),"SpatialGridDataFrame")
spplot(meuse.grid[,,"soil"])

meuse.grid$soil[meuse.grid$soil==1] <- 4
meuse.grid$soil[meuse.grid$soil==2 | meuse.grid$soil==3] <- 5
spplot(meuse.grid[,,"soil"])

Hope that helps,
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