<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
I am trying to plot 100 variograms from 100 CSGS realizations in a
single plot with the observed variogram model. I used following codes
to plot them together. But problem is this code is: I have to create
variogram for all realizations, ie 100 times I have to repeat this
code! <br>
This their any way to run following codes with in a loop to create a
plot of variograms of all realizations with observed variogram model.
Help will be appreciated. <br>
Thanks<br>
Zia<br>
<br>
<br>
l<small><font face="Courier New, Courier, monospace">ibrary(gstat)<br>
data(meuse)<br>
data(meuse.grid)<br>
coordinates(meuse) = ~x + y<br>
coordinates(meuse.grid) = ~x + y<br>
<br>
# Variogram log Zn<br>
<br>
lzn.vgm = variogram(log(zinc) ~ 1, meuse)<br>
lzn.fit = fit.variogram(lzn.vgm, model = vgm(1, "Sph", 900, 1))<br>
<br>
#Conditional simulation<br>
<br>
lzn.sim = krige(log(zinc) ~ 1, meuse, meuse.grid, model = lzn.fit,<br>
nmax = 30, nsim = 100)<br>
<br>
# Variogram of all relizations<br>
<br>
var.sim1<-variogram(sim1~1, lzn.sim) # Realization 1 <br>
var.sim2<-variogram(sim2~1, lzn.sim) # Realization 2<br>
var.sim3<-variogram(sim3~1, lzn.sim) # Realization 3<br>
var.sim4<-variogram(sim4~1, lzn.sim) # Realization 4<br>
.<br>
.<br>
.<br>
var.sim100<-variogram(sim100~1, lzn.sim) # Realization 100<br>
<br>
# Vriogram of observed data and all relaizations<br>
##################################################<br>
<br>
plot(lzn.vgm$gamma ~ lzn.vgm$dist, xlim = c(0, max(lzn.vgm$dist) *
1.05),<br>
ylim = c(0, max(lzn.vgm$gamma) * 1.2), pch = 21, col = "black",cex=.8,<br>
cex.axis = 0.85, cex.lab=.8, xlab = "Distance (m)", ylab =
"Semivariance")<br>
<br>
lines(variogramLine(fit.variogram(lzn.vgm, lzn.fit), # Sim1<br>
maxdist = max(lzn.vgm$dist)), col = "red", lwd=2)<br>
<br>
lines(variogramLine(fit.variogram(var.sim1, lzn.fit), # sim2<br>
maxdist = max(lzn.vgm$dist)), col = "black", lty=1)<br>
<br>
lines(variogramLine(fit.variogram(var.sim2, lzn.fit), # Sim3<br>
maxdist = max(lzn.vgm$dist)), col = "black", lty=1)<br>
<br>
lines(variogramLine(fit.variogram(var.sim3, lzn.fit), # Sim4<br>
maxdist = max(lzn.vgm$dist)), col = "black", lty=1)<br>
.<br>
.<br>
.<br>
.<br>
lines(variogramLine(fit.variogram(var.sim100, lzn.fit), # Sim100<br>
maxdist = max(lzn.vgm$dist)), col = "black", lty=1) </font></small><br>
<br>
<br>
</body>
</html>