[R-sig-Geo] Adding values to a raster

Tara Bridwell tarabridwell at gmail.com
Sun Sep 18 01:48:35 CEST 2011


I have a dataset that consists of point coordinates and values
associated with the points.  I want to be able to grid the values, and
then do calulations using the values using the various raster
functions.  I am, however, finding this difficult to do.  I have tried
a number of functions including rasterize, SpatialGridDataFrame, and
SpatialGridDataFrame but I think I am missing a bit of the theory
behind this that I can't seem to piece together. I have the Applied
Spatial Data Analysis (Bivand) but couldn't seem to find an
appropriate section.  Here is an example data set:

require(raster)

r <- raster(ncol=10, nrow=10)

r[]=1:ncell(r)

x <- c(-45, 30, 20, -10, 50, -7)

y <- c(-25, -148, 46, 23, 0, -69)

value <- c(1, 2, 3, 4, 5, 6)

coord.plus.value <- cbind(x, y, value)

coord.plus.value_sp <- SpatialPoints(coord.plus.value)

>From here I want to plot 'value' using the raster 'r'.

Suggests on how to do this, as well as thoughts on the basic theory I
seem to be missing (or where in the Bivand book I should be reading
that I have missed) would be appreciated.

Thank you,

Tara Bridwell



More information about the R-sig-Geo mailing list