[R-sig-Geo] raster::raster from SpatialPixelsDataFrame object

Agustin Lobo alobolistas at gmail.com
Thu Jan 23 16:17:10 CET 2014


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 at data <- data.frame(name="A",m at 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?

r2 <- rasterize(x=m,y=r, field="dist")

It would make sense doing this in just one command.

Thanks

Agus



More information about the R-sig-Geo mailing list