Chapter 3. GSTAT from Matlab

Table of Contents

Working with GSTAT and mGstat
The GSTAT parameter file in mGstat
An interactive GSTAT session in Matlab
GSTAT-related m-files
GSTAT examples
GSTAT ex03
GSTAT ex04
GSTAT ex05
GSTAT ex06
GSTAT ex07
GSTAT ex09
GSTAT ex10

This chapter discuss how to run GSTAT from within Matlab.

Working with GSTAT and mGstat

The GSTAT parameter file in mGstat

GSTAT can be run non-interactively using by parsing a parameter file. It is by reading and writing this printer file that mGstat interfaces with GSTAT. Consider the following GSTAT parameter file

# Local simple point kriging on a mask map
data(ln_zinc): 'zinc.eas', x=1, y=2, v=3, log,
  min=20, max=40, radius=1000, sk_mean=5.9;
variogram(ln_zinc): 0.0554 Nug(0) + 0.581 Sph(900);
mask:                 'mask_map';
predictions(ln_zinc): 'lzn_skpr';
variances(ln_zinc):   'lzn_skvr';

using read_gstat_par to read the parameter into the data structure G, gives

>> G=read_gstat_par(par)
G =
         mgstat: [1x1 struct]
           data: {[1x1 struct]}
      variogram: {[1x1 struct]}
           mask: {[1x1 struct]}
    predictions: {[1x1 struct]}
      variances: {[1x1 struct]}

>> G.mgstat
ans =
    parfile: '/home/tmh/RESEARCH/PROGRAMMING/gstat-2.4.4/cmd/ex05.cmd'
    comment: {'#'  '#Local simple point kriging on a mask map'  '#'}

ans =
       data: 'ln_zinc'
       file: 'zinc.eas'
          x: 1
          y: 2
          v: 3
        log: ''
        min: 20
        max: 40
     radius: 1000
    sk_mean: 5.9000

>> G.predictions{1}
ans =
    data: 'ln_zinc'
    file: 'lzn_skpr'

The mgstat field to the G structure, is specific to mGstat and stores the comments of the parameter file, and the location on disk of the parameter file.

The rest of the fields of G refers to lines in the GSTAT parameter file.

'data' field of GSTAT parameter file

Take for example the data field as listed above. The field is called data, because this is the identifier (first string) in the parameter file. Filename and data identifiers are always specified using 'data' and 'file' fields. Several options can be specified for the 'data'. This are simply listed as fields of{1}. If an option does not supply a value (as the 'log' option) it simply refers to an empty string.

In case several data type are listed in the parameter file, they are read into separate structures, as{1},{2} ,...

An interactive GSTAT session in Matlab

to come