makeGstatCmd: Make a gstat command script

Description Usage Arguments Details Note Author(s) References See Also Examples

Description

Generates a command script based on the regression model and variogram. This can then be used to run predictions/simulations by using the pre-compiled binary gstat.exe.

Usage

1
2
3
4
makeGstatCmd(formString, vgmModel, outfile, easfile, 
        nsim = 0, nmin = 20, nmax = 40, radius, zmap = 0, 
        predictions = "var1.pred.hdr", variances = "var1.svar.hdr", 
        xcol = 1, ycol = 2, zcol = 3, vcol = 4, Xcols)

Arguments

formString

object of class "formula" — regression model

vgmModel

object of class "vgmmodel" or "data.frame"

outfile

character; output file for the command script

easfile

character; file name for the GeoEAS file with observed values

nsim

integer; number of simulations

nmin

integer; smallest number of points in the search radius (see gstat user's manual)

nmax

integer; largest number of points in the search radius (see gstat user's manual)

radius

numeric; search radius (see gstat user's manual)

zmap

numeric; fixed value for the 3D dimension in the case of 3D kriging

predictions

character; output file name for predictions

variances

character; output file name for kriging variances

xcol

integer; position of the x column in the GeoEAS file

ycol

integer; position of the y column in the GeoEAS file

zcol

integer; position of the z column in the GeoEAS file

vcol

integer; position of the target variable column in the GeoEAS file

Xcols

integer; column numbers for the list of covariates

Details

To run the script under Windows OS you need to obtain the pre-compiled gstat.exe program from the www.gstat.org website, and put it in some directory e.g. c:/gstat/. Then add the program to your path (see environmental variable under Windows > Control panel > System > Advanced > Environmental variables), or copy the exe program directly to some windows system directory.

Note

The advantage of using gstat.exe is that it loads large grids much faster to memory than if you use gstat in R, hence it is potentially more suited for computing with large grids. The draw back is that you can only pass simple linear regression models to gstat.exe. The stand-alone gstat is not maintained by the author of gstat any more.

Author(s)

Tomislav Hengl

References

See Also

write.data, fit.gstatModel, gstat::krige

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
library(sp)
library(gstat)

# Meuse data:
demo(meuse, echo=FALSE)
# fit a model:
omm <- fit.gstatModel(observations = meuse, formulaString = om~dist, 
  family = gaussian(log), covariates = meuse.grid)
str(omm@vgmModel)
# write the regression matrix to GeoEAS:
meuse$log_om <- log1p(meuse$om)
write.data(obj=meuse, covariates=meuse.grid["dist"], 
    outfile="meuse.eas", methodid="log_om")
writeGDAL(meuse.grid["dist"], "dist.rst", drivername="RST", mvFlag="-99999")
makeGstatCmd(log_om~dist, vgmModel=omm@vgmModel, 
    outfile="meuse_om_sims.cmd", easfile="meuse.eas", 
    nsim=50, nmin=20, nmax=40, radius=1500)
# compare the processing times:
system.time(system("gstat meuse_om_sims.cmd"))
vgmModel = omm@vgmModel
class(vgmModel) <- c("variogramModel", "data.frame")
system.time(om.rk <- krige(log_om~dist, meuse[!is.na(meuse$log_om),], 
    meuse.grid, nmin=20, nmax=40, model=vgmModel, nsim=50))

## End(Not run)

GSIF documentation built on May 2, 2019, 5:44 p.m.

Related to makeGstatCmd in GSIF...