[R-sig-Geo] Generate Spatial Surface

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Oct 16 17:36:50 CEST 2012



On 10/16/2012 05:26 PM, dani jon wrote:
> Hi All,
> 
> 
> I am trying to figure out how to simulate a continuous spatial surface with
> strong spatial autocorrelation. Then, I would like to divide this spatial
> surface into by 8 x 8 grids and take a sample of 15 locations within each
> grid and the corresponding values.
> For example, here is a sample code adopted from Santiago
> Beguería<http://santiago.begueria.es/>.
> 
> 
> library(gstat)
> 
> xy <- expand.grid(1:100, 1:100)
> 
> names(xy) <- c("x","y")
> 
> g.dummy <- gstat(formula=z~1, locations=~x+y, dummy=T, beta=1,
> model=vgm(psill=0.025,model="Exp",range=10), nmax=20)
> 
> # Make four simulations based on the gstat object
> 
> yy <- predict(g.dummy, newdata=xy, nsim=1)
> 
> # show one realization
> 
> gridded(yy) = ~x+y
> 
> spplot(yy[1])
> My questions is how to divide this spatial surface into 8x8 girds and then
> take a sample of 15 locations and their values? I would greatly appreciate
> if anybody can provide some ideas or pointers how to implement these
> scenarios in R. Thanks all for your help! Dani

does

x = spsample(yy, type = "stratified", cellsize = 12)[sample(64,15),]
spplot(yy[1], sp.layout = list("sp.points", x))

kind of do what you want?

> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list