# or more directly: data(meuse.grid) rasterFromXYZ(meuse.grid[,c(1:2, 5)])
# or via a RasterBrick m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data = meuse.grid) m@data <- data.frame(name="A",m@data) b <- brick(m) b[["ffreq"]] # also: there is no "raster" object (there is a function) in the raster package. You mean 'RasterLayer' On Thu, Jan 23, 2014 at 7:36 AM, Edzer Pebesma <edzer.pebe...@uni-muenster.de> wrote: > > > On 01/23/2014 04:17 PM, Agustin Lobo wrote: >> In order to convert a SpatialPixelsDataFrame object "m" into a raster I just >> do >> data(meuse.grid) >> m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data = >> meuse.grid) >> m@data <- data.frame(name="A",m@data) >> r <- raster(m) >> >> but the actual values are taken from the first column as I'm not >> selecting the numeric field in >> the table. >> Is there a way to select the field as in rasterize? > > you mean, like in: > > r <- raster(m[3]) > > or > > r <- raster(m["ffreq"]) > > ? > >> >> r2 <- rasterize(x=m,y=r, field="dist") >> >> It would make sense doing this in just one command. >> >> Thanks >> >> Agus >> >> _______________________________________________ >> R-sig-Geo mailing list >> R-sig-Geo@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> > > -- > Edzer Pebesma > Institute for Geoinformatics (ifgi), University of Münster > Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251 > 83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795 > > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo