Skip to content
Prev 3219 / 29559 Next

class ker (ks) --> conversion --> raster

On Wed, 27 Feb 2008, Nicolas Bergeron wrote:

            
So far so good - an example:

library(ks)
library(sp)
data(meuse)
xy <- cbind(meuse$x, meuse$y)
HpiScale <- Hpi(x=xy, pilot="samse", pre="scale")
fhat.HpiScale <- kde(x=xy, H = HpiScale)
plot(fhat.HpiScale)
im <- list(x=fhat.HpiScale$eval.points[[1]],
  y=fhat.HpiScale$eval.points[[2]], z=fhat.HpiScale$estimate)
# make an image-style list
image(im)
contour(im)
SPim <- image2Grid(im)
# convert the image-style list to a SpatialGridDataFrame object,
# thanks to Mike Sumner for code now in sp
image(SPim)

So now we have a SpatialGridDataFrame (note that the values are very 
small, consider re-scaling).
grid (r.in.arc in GRASS), writeGDAL() in rgdal and r.in.gdal in GRASS with 
a suitable driver, or writeRAST6() in spgrass6 to write a 
SpatialGridDataFrame to GRASS using temporary files.

Hope this helps,

Roger