Skip to content

v.kriging

Interpolates 2D or 3D raster based on input values located on 2D or 3D point vector layer (method ordinary kriging extended to 3D).

v.kriging [-2but] input=name [layer=string] phase=string [report=name] [hz_function=string] [output=string] [crossvalid=name] [vert_function=string] [final_function=string] [final_vert_function=string] [atrend=float] [btrend=float] [ctrend=float] [dtrend=float] [fileformat=string] icolumn=name [zcolumn=name] [azimuth=float] [zenith_angle=float] [lmax=float] [vmax=float] [lpieces=integer] [vpieces=integer] [td=float] [hz_nugget=float] [vert_nugget=float] [final_nugget=float] [final_vert_nugget=float] [hz_sill=float] [vert_sill=float] [final_sill=float] [final_vert_sill=float] [hz_range=float] [vert_range=float] [final_range=float] [final_vert_range=float] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

v.kriging input=name phase=string icolumn=name

grass.script.run_command("v.kriging", input, layer="1", phase, report=None, hz_function=None, output=None, crossvalid=None, vert_function=None, final_function=None, final_vert_function=None, atrend=0.0, btrend=0.0, ctrend=0.0, dtrend=0.0, fileformat=None, icolumn, zcolumn=None, azimuth=45.0, zenith_angle=0.0, lmax=None, vmax=None, lpieces=None, vpieces=None, td=45.0, hz_nugget=0.0, vert_nugget=0.0, final_nugget=0.0, final_vert_nugget=0.0, hz_sill=None, vert_sill=None, final_sill=None, final_vert_sill=None, hz_range=None, vert_range=None, final_range=None, final_vert_range=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.run_command("v.kriging", input="name", phase="string", icolumn="name")

grass.tools.Tools.v_kriging(input, layer="1", phase, report=None, hz_function=None, output=None, crossvalid=None, vert_function=None, final_function=None, final_vert_function=None, atrend=0.0, btrend=0.0, ctrend=0.0, dtrend=0.0, fileformat=None, icolumn, zcolumn=None, azimuth=45.0, zenith_angle=0.0, lmax=None, vmax=None, lpieces=None, vpieces=None, td=45.0, hz_nugget=0.0, vert_nugget=0.0, final_nugget=0.0, final_vert_nugget=0.0, hz_sill=None, vert_sill=None, final_sill=None, final_vert_sill=None, hz_range=None, vert_range=None, final_range=None, final_vert_range=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.v_kriging(input="name", phase="string", icolumn="name")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

input=name [required]
    Name of input vector points map
    Or data source for direct OGR access
layer=string
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Default: 1
phase=string [required]
    Phase of interpolation. In the initial phase, there is empirical variogram computed. In the middle phase, function of theoretical variogram is chosen by the user and its coefficients are estimated empirically. In the final phase, unknown values are interpolated using theoretical variogram from previous phase.
    Allowed values: initial, middle, final
report=name
    File to write the report
hz_function=string
    Horizontal variogram function
    Allowed values: linear, exponential, spherical, gaussian, bivariate
output=string
    Name for output 2D/3D raster map
crossvalid=name
    File to write the results of cross validation
vert_function=string
    Vertical variogram function
    Allowed values: linear, exponential, spherical, gaussian, bivariate
final_function=string
    Final variogram function (anisotropic or horizontal component of bivariate variogram)
    Allowed values: linear, exponential, spherical, gaussian, bivariate
final_vert_function=string
    Final variogram function (vertical component of bivariate variogram)
    Allowed values: linear, exponential, spherical, gaussian, bivariate
atrend=float
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
btrend=float
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
ctrend=float
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
dtrend=float
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
fileformat=string
    File format to save variogram plot (empty: preview in Gnuplot terminal)
    Allowed values: cdr, dxf, eps, tex, pdf, png, svg
icolumn=name [required]
    Attribute column containing input values for interpolation
zcolumn=name
    Attribute column containing z coordinates (only for 3D interpolation based on 2D point layer)
azimuth=float
    Azimuth of variogram computing (isotrophic)
    Default: 45.0
zenith_angle=float
    Zenith angle of variogram computing (isotrophic)
    Default: 0.0
lmax=float
    Maximum distance in horizontal direction
vmax=float
    Maximum distance in horizontal direction (only for 3D variogram)
lpieces=integer
    Number of horizontal lags
vpieces=integer
    Number of vertical lags (only for 3D variogram)
td=float
    Angle of variogram processing
    Default: 45.0
hz_nugget=float
    Nugget effect of horizontal variogram
    Default: 0.0
vert_nugget=float
    Nugget effect of vertical variogram
    Default: 0.0
final_nugget=float
    Nugget effect of anisotropic variogram (or horizontal component of bivariate variogram)
    Default: 0.0
final_vert_nugget=float
    For bivariate variogram only: nuget effect of vertical component
    Default: 0.0
hz_sill=float
    Sill of horizontal variogram
vert_sill=float
    Sill of vertical variogram
final_sill=float
    Sill of anisotropic variogram (or horizontal component of bivariate variogram)
final_vert_sill=float
    For bivariate variogram only: sill of vertical component
hz_range=float
    Range of horizontal variogram
vert_range=float
    Range of vertical variogram
final_range=float
    Range of anisotropic variogram (or horizontal component of bivariate variogram)
final_vert_range=float
    Range of final variogram: one value for anisotropic, two values for bivariate (hz and vert component)
-2
    Force 2D interpolation even if input is 3D
-b
    Compute bivariate variogram (3D interpolation only)
-u
    Compute univariate variogram (3D interpolation only)
-t
    Eliminate trend if variogram is parabolic
--overwrite
    Allow output files to overwrite existing files
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

input : str, required
    Name of input vector points map
    Or data source for direct OGR access
    Used as: input, vector, name
layer : str, optional
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Used as: input, layer
    Default: 1
phase : str, required
    Phase of interpolation. In the initial phase, there is empirical variogram computed. In the middle phase, function of theoretical variogram is chosen by the user and its coefficients are estimated empirically. In the final phase, unknown values are interpolated using theoretical variogram from previous phase.
    Allowed values: initial, middle, final
report : str, optional
    File to write the report
    Used as: output, file, name
hz_function : str, optional
    Horizontal variogram function
    Allowed values: linear, exponential, spherical, gaussian, bivariate
output : str, optional
    Name for output 2D/3D raster map
crossvalid : str, optional
    File to write the results of cross validation
    Used as: output, file, name
vert_function : str, optional
    Vertical variogram function
    Allowed values: linear, exponential, spherical, gaussian, bivariate
final_function : str, optional
    Final variogram function (anisotropic or horizontal component of bivariate variogram)
    Allowed values: linear, exponential, spherical, gaussian, bivariate
final_vert_function : str, optional
    Final variogram function (vertical component of bivariate variogram)
    Allowed values: linear, exponential, spherical, gaussian, bivariate
atrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
btrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
ctrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
dtrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
fileformat : str, optional
    File format to save variogram plot (empty: preview in Gnuplot terminal)
    Allowed values: cdr, dxf, eps, tex, pdf, png, svg
icolumn : str, required
    Attribute column containing input values for interpolation
    Used as: input, dbcolumn, name
zcolumn : str, optional
    Attribute column containing z coordinates (only for 3D interpolation based on 2D point layer)
    Used as: input, dbcolumn, name
azimuth : float, optional
    Azimuth of variogram computing (isotrophic)
    Default: 45.0
zenith_angle : float, optional
    Zenith angle of variogram computing (isotrophic)
    Default: 0.0
lmax : float, optional
    Maximum distance in horizontal direction
vmax : float, optional
    Maximum distance in horizontal direction (only for 3D variogram)
lpieces : int, optional
    Number of horizontal lags
vpieces : int, optional
    Number of vertical lags (only for 3D variogram)
td : float, optional
    Angle of variogram processing
    Default: 45.0
hz_nugget : float, optional
    Nugget effect of horizontal variogram
    Default: 0.0
vert_nugget : float, optional
    Nugget effect of vertical variogram
    Default: 0.0
final_nugget : float, optional
    Nugget effect of anisotropic variogram (or horizontal component of bivariate variogram)
    Default: 0.0
final_vert_nugget : float, optional
    For bivariate variogram only: nuget effect of vertical component
    Default: 0.0
hz_sill : float, optional
    Sill of horizontal variogram
vert_sill : float, optional
    Sill of vertical variogram
final_sill : float, optional
    Sill of anisotropic variogram (or horizontal component of bivariate variogram)
final_vert_sill : float, optional
    For bivariate variogram only: sill of vertical component
hz_range : float, optional
    Range of horizontal variogram
vert_range : float, optional
    Range of vertical variogram
final_range : float, optional
    Range of anisotropic variogram (or horizontal component of bivariate variogram)
final_vert_range : float, optional
    Range of final variogram: one value for anisotropic, two values for bivariate (hz and vert component)
flags : str, optional
    Allowed values: 2, b, u, t
    2
        Force 2D interpolation even if input is 3D
    b
        Compute bivariate variogram (3D interpolation only)
    u
        Compute univariate variogram (3D interpolation only)
    t
        Eliminate trend if variogram is parabolic
overwrite : bool, optional
    Allow output files to overwrite existing files
    Default: None
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

input : str, required
    Name of input vector points map
    Or data source for direct OGR access
    Used as: input, vector, name
layer : str, optional
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Used as: input, layer
    Default: 1
phase : str, required
    Phase of interpolation. In the initial phase, there is empirical variogram computed. In the middle phase, function of theoretical variogram is chosen by the user and its coefficients are estimated empirically. In the final phase, unknown values are interpolated using theoretical variogram from previous phase.
    Allowed values: initial, middle, final
report : str, optional
    File to write the report
    Used as: output, file, name
hz_function : str, optional
    Horizontal variogram function
    Allowed values: linear, exponential, spherical, gaussian, bivariate
output : str, optional
    Name for output 2D/3D raster map
crossvalid : str, optional
    File to write the results of cross validation
    Used as: output, file, name
vert_function : str, optional
    Vertical variogram function
    Allowed values: linear, exponential, spherical, gaussian, bivariate
final_function : str, optional
    Final variogram function (anisotropic or horizontal component of bivariate variogram)
    Allowed values: linear, exponential, spherical, gaussian, bivariate
final_vert_function : str, optional
    Final variogram function (vertical component of bivariate variogram)
    Allowed values: linear, exponential, spherical, gaussian, bivariate
atrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
btrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
ctrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
dtrend : float, optional
    Trend: f(x,y,z) = a*x + b*y + c*z + d
    Default: 0.0
fileformat : str, optional
    File format to save variogram plot (empty: preview in Gnuplot terminal)
    Allowed values: cdr, dxf, eps, tex, pdf, png, svg
icolumn : str, required
    Attribute column containing input values for interpolation
    Used as: input, dbcolumn, name
zcolumn : str, optional
    Attribute column containing z coordinates (only for 3D interpolation based on 2D point layer)
    Used as: input, dbcolumn, name
azimuth : float, optional
    Azimuth of variogram computing (isotrophic)
    Default: 45.0
zenith_angle : float, optional
    Zenith angle of variogram computing (isotrophic)
    Default: 0.0
lmax : float, optional
    Maximum distance in horizontal direction
vmax : float, optional
    Maximum distance in horizontal direction (only for 3D variogram)
lpieces : int, optional
    Number of horizontal lags
vpieces : int, optional
    Number of vertical lags (only for 3D variogram)
td : float, optional
    Angle of variogram processing
    Default: 45.0
hz_nugget : float, optional
    Nugget effect of horizontal variogram
    Default: 0.0
vert_nugget : float, optional
    Nugget effect of vertical variogram
    Default: 0.0
final_nugget : float, optional
    Nugget effect of anisotropic variogram (or horizontal component of bivariate variogram)
    Default: 0.0
final_vert_nugget : float, optional
    For bivariate variogram only: nuget effect of vertical component
    Default: 0.0
hz_sill : float, optional
    Sill of horizontal variogram
vert_sill : float, optional
    Sill of vertical variogram
final_sill : float, optional
    Sill of anisotropic variogram (or horizontal component of bivariate variogram)
final_vert_sill : float, optional
    For bivariate variogram only: sill of vertical component
hz_range : float, optional
    Range of horizontal variogram
vert_range : float, optional
    Range of vertical variogram
final_range : float, optional
    Range of anisotropic variogram (or horizontal component of bivariate variogram)
final_vert_range : float, optional
    Range of final variogram: one value for anisotropic, two values for bivariate (hz and vert component)
flags : str, optional
    Allowed values: 2, b, u, t
    2
        Force 2D interpolation even if input is 3D
    b
        Compute bivariate variogram (3D interpolation only)
    u
        Compute univariate variogram (3D interpolation only)
    t
        Eliminate trend if variogram is parabolic
overwrite : bool, optional
    Allow output files to overwrite existing files
    Default: None
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

Returns:

result : grass.tools.support.ToolResult | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None will be returned.

Raises:

grass.tools.ToolError: When the tool ended with an error.

DESCRIPTION

v.kriging constructs 2D / 3D raster from the values located on discrete points using interpolation method ordinary kriging. In order to let the user decide on the process and necessary parameters, the module performance is divided into three phases:

  • initial phase computes experimental variogram.
  • Please set up a name of the report file. The file will be created automatically in working directory to enable import of parameters from current to following phases. If the file has been deleted during the module performance, the user is asked to start interpolation again from the initial phase.
  • Warning about particular point and "less than 2 neighbours in its closest surrounding. The perimeter of the surrounding will be increased..." indicates that variogram range should be shortened.
  • There will appear some temporary files during variogram computation. They will be deleted automatically in following phase. If missing, the user is asked to repeat initial phase.
  • It is not necessary to save experimental variogram plots. They just help to estimate parameters of theoretical variogram that will be computed in following step (output contains experimental and theoretical variogram plotted together).
  • in the middle phase, the user estimates theoretical variogram setting up the range (if necessary, the sill and the nugget effect as well) to fit the experimental variogram from previous phase.
  • Default sill is calculated from variogram values, more details in (Stopkova, 2014).
  • Save horizontal and vertical variogram plots using file=extension.
  • Experimental anisotropic / bivariate variogram is plotted as a base for final theoretical variogram parameters estimation in final phase.
  • final phase performs interpolation based on parameters of theoretical variogram.
  • Save anisotropic or bivariate variogram plot using file=extension.

EXAMPLES

To get optimal results, it is necessary to test various initial settings, anisotropic ratios and variogram functions. Input (2D or 3D point layer) must contain values to be interpolated in the attribute table.

3D kriging

General commands:

v.kriging phase=initial in=input_layer icol=name report=report_file.txt file=png
v.kriging in=input_layer phase=middle hz_fun=exponential vert_fun=exponential ic=name file=png  \
hz_range=double vert_range=double [hz_sill=double vert_sill=double hz_nugget=double vert_nugget=double] -u
v.kriging in=input_layer phase=final final_fun=exponential final_range=double \
[final_sill=double final_nugget=double] icol=name file=png out=name crossval=crossval_file.txt

Commands based on the dataset of Slovakia 3D precipitation (Mitasova and Hofierka, 2004). For more detailed information check case studies. Another examples of 3D interpolation are available in (Stopkova, 2014).

v.kriging phase=initial in=precip3d@PERMANENT ic=precip report=precip3d.txt file=png --o
v.kriging in=precip3d@PERMANENT phase=middle hz_fun=exponential vert_fun=gaussian ic=precip file=png hz_range=100000. vert_range=1600 --o -u
v.kriging in=precip3d@PERMANENT phase=middle hz_fun=exponential vert_fun=gaussian ic=precip \
file=png hz_range=100000. vert_range=1600 --o -u

Note: 3D points in this example are concentrated on the Earth's surface. Thus the deeper / higher, the less accurate result of interpolation.

2D kriging

General commands:

v.kriging phase=initial in=input_layer icol=name report=report_file.txt file=png -2
v.kriging in=input_layer phase=final final_function=linear icol=name file=png \
  out=name crossval=crossval_file.txt -2

Commands based on 500 random points extracted from input points of Digital Elevation Model (DEM) elev_lid792_randpts from the North Carolina dataset (Neteler and Mitasova, 2004). See the case studies.

v.kriging phase=initial in=elev_lid792_selected ic=value azimuth=45. td=45. \
report=lid792_500_linear.txt -2 --o
v.kriging in=elev_lid792_selected phase=final final_function=linear ic=value \
file=png out=lid792_500_linear crossval=lid792_500_xval_linear.txt -2 --o

TODO

  • anisotropy in horizontal direction missing
  • current version is suitable just for metric coordinate systems
  • enable mask usage
  • bivariate variogram needs to be rebuilt (theory)
  • 2D interpolation from 3D input layer needs to be rebuilt (especially in case that there are too many points located on identical horizontal coordinates with different elevation)

Recommendations

  • In case of too much warnings about input points that have "less than 2 neighbours in its closest surrounding. The perimeter of the surrounding will be increased...", please consider shorter variogram range.
  • Save just figures with theoretical variogram (using file=extension in the middle and final phase). Experimental variograms are included in the theoretical variogram plot and separate "experimental" plots can be just temporal.

REFERENCES

Mitasova, H. and Hofierka, J. (2004). Slovakia Precipitation data. Available at https://grass.osgeo.org/download/data/.

Neteler, M. and Mitasova, H. (2004). Open Source GIS: A GRASS GIS Approach. 2nd Ed. 401 pp, Springer, New York. Online Supplement: https://grassbook.org

Stopkova, E. (2014). Development and application of 3D analytical functions in spatial analyses (Unpublished doctoral dissertation). The Department of Theoretical Geodesy, Faculty of Civil Engineering of Slovak University of Technology in Bratislava, Slovakia.

SEE ALSO

v.vol.rst
v.krige

REQUIREMENTS

AUTHOR

Eva Stopkova
functions taken from another modules are cited above the function or at the beginning of the file (e.g. quantile.cpp that uses slightly modified functions taken from the module r.quantile (Clements, G.))

SOURCE CODE

Available at: v.kriging source code (history)
Latest change: Tuesday Feb 17 11:09:03 2026 in commit 9d70ce7