Skip to content

v.surf.nnbathy

Interpolates a raster map using the nnbathy natural neighbor interpolation program.

v.surf.nnbathy [input=name] [layer=string] [file=name] output=name [column=name] [where=sql_query] [algorithm=string] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

v.surf.nnbathy output=name

grass.script.run_command("v.surf.nnbathy", input=None, layer="1", file=None, output, column=None, where=None, algorithm="nn", overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("v.surf.nnbathy", output="name")

Parameters

input=name
    Name of input vector map
    Name of input vector points map
layer=string
    Layer number
    If set to 0, z coordinates are used. (3D vector only)
    Default: 1
file=name
    Containing x,y,z data as three space separated columns
output=name [required]
    Name of output raster map
column=name
    Name of the attribute column with values to be used for approximation (if layer>0)
where=sql_query
    WHERE conditions of SQL statement without 'where' keyword
    Example: income < 1000 and population >= 10000
algorithm=string
    Settings
    Allowed values: l, nn, ns
    Default: nn
    l: Linear
    nn: Sibson natural neighbor
    ns: Non-Sibsonian natural neighbor
--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, optional
    Name of input vector map
    Name of input vector points map
    Used as: input, vector, name
layer : str, optional
    Layer number
    If set to 0, z coordinates are used. (3D vector only)
    Used as: input, layer
    Default: 1
file : str, optional
    Containing x,y,z data as three space separated columns
    Used as: input, file, name
output : str, required
    Name of output raster map
    Used as: output, raster, name
column : str, optional
    Name of the attribute column with values to be used for approximation (if layer>0)
    Used as: input, dbcolumn, name
where : str, optional
    WHERE conditions of SQL statement without 'where' keyword
    Example: income < 1000 and population >= 10000
    Used as: input, sql_query, sql_query
algorithm : str, optional
    Settings
    Allowed values: l, nn, ns
    l: Linear
    nn: Sibson natural neighbor
    ns: Non-Sibsonian natural neighbor
    Default: nn
overwrite: bool, optional
    Allow output files to overwrite existing files
    Default: False
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

v.surf.nnbathy is an interface between the external nnbathy utility and GRASS. nnbathy is a surface interpolation program provided with nn - a natural neighbor interpolation library, written by Pavel Sakov.

v.surf.nnbathy provides 3 interpolation algorithms. According to nn library documentation these are: Delaunay interpolation (alg=l), Watson's algortithm for Sibson natural neighbor interpolation (alg=nn) and Belikov and Semenov's algorithm for non-Sibsonian natural neighbor interpolation (alg=ns). For performing the underlaying Delaunay triangulation in all cases nnbathy uses triangle software by Jonathan Richard Shewchuk.

The output raster map is a continous surface interpolated from the input or file data.

NOTES

nnbathy, if built with '-DNN_SERIAL' (default as of nn 1.85), is able to create a grid of virtually any size. It interpolates and writes one output point at a time only. This eliminates the necessity to hold the whole output array in memory. However, even then all the input points are still held in the memory.

  1. Requires GRASS 7 and nnbathy 1.76 or greater.
  2. Build nnbathy according to instructions provided with its source code and put it somewhere in your $PATH.
  3. The output raster map extent and resolution match the region settings at which the script was started.
  4. The output raster map non-NULL area is limited to the convex hull encompassing all the non-NULL input cells.
  5. The output is double precision floating point raster map (DCELL).
  6. Natural neighbor is a an exact interpolation algorithm, so all non-NULL input points have their value exactly preserved in the output.
  7. There is circa 0.2 KB memory overhead per each input cell. However, the output grid can be of any size, if nnbathy is built with -DNN_SERIAL switch.
  8. v.surf.nnbathy creates 4 temporary files: ASCII x,y,z lists of the input points and output cells, and the output list converted into GRASS ASCII format. Then it makes a GRASS raster map from the latter
    • and only then it removes the 3 temp files, when the script terminates. Thus, at the script run time several times more disk space might be required, than the final GRASS raster map would actually occupy.

EXAMPLE

g.region raster=elevationelev_lid792_randpts@PERMANENT -p
v.surf.nnbathy input=elevation_lid792_randpts@PERMANENT output=raster_map column=value
d.rast map=raster_map

REQUIREMENTS

SEE ALSO

r.surf.nnbathy

AUTHORS

Adam Laza, OSGeoREL, Czech Technical University in Prague (mentor: Martin Landa) Corrected by Roberto Marzocchi, roberto.marzocchi@gter.it

Based on v.surf.nnbathy from GRASS 6 by:
Hamish Bowman, Otago University, New Zealand
Based on r.surf.nnbathy by Maciej Sieczka

SOURCE CODE

Available at: v.surf.nnbathy source code (history)
Latest change: Friday Feb 21 10:10:05 2025 in commit 7d78fe3