Skip to content
Prev 3661 / 29559 Next

Defining a grid for interpolations ?

Hi Mauricio,

To get a grid based on a shapefile you can use the command "spsample".

library(sp)
library(maptools)
source_poly = readShapePoly("/path/to/poly")
# cellsize is in map units (e.g. km), also see "?spsample"
grd = spsample(source_poly, cellsize = c(10e3,10e3), type = "regular")
gridded(grd) = TRUE # Make it a grid
summary(grd)
# Visualize the grid
spplot(source_poly, sp.layout = list("sp.points", grd))

"grd" can now be used for interpolations.

hth and cheers,
Paul
Mauricio Zambrano wrote: