[R] Simulating a landscape (matrix) in R

Victor Gravenholt vicgrave at hotmail.com
Thu Jun 3 23:38:08 CEST 2004


You could try something like this.
Simulating with a large number of grid cells is however very RAM expensive.

library(MASS)
library(spatial)
 x <- expand.grid(1:30, 1:30)
 distances <- as.matrix(dist(x, diag=T, upper=T))
 Sigma <- expcov(r=distances, d=10, se=1) 
 z <- mvrnorm(n = 1, mu=rep(0,900), Sigma) 
 z <- matrix(z,nrow=30)
 image(z)



----- Original Message ----- 
From: "Brian Davenhall" <bdavenhall at sbcglobal.net>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, June 03, 2004 10:46 PM
Subject: [R] Simulating a landscape (matrix) in R


> I'm trying to figure out how one might go about simulating a landscape
> (matrix) in R.  For example if one wanted to generate a simulated landscape
> of precipitation values for some area (say a 100 X 100 matrix) they could
> generate 10,000 numbers using a random normal distribution with a mean and
> std. dev. and randomly allocate these generated numbers to the grid cells.
> However, this is too simplistic and the resulting matrix will be very noisy
> since one cell could have a very high value and an adjacent cell could have
> a very low value.  Is it possible to generate a simulated matrix that would
> somehow incorporate a measure of spatial autocorrelation, so that grid cells
> closer to each other are similar?
> 
>  
> 
> Is this sort of thing possible in R to get a realistic surface or are other
> software packages (e.g., surface visualizations/rendering) more appropriate
> for this sort of thing?
> 
> 
> [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list