NNINT

Natural neighbor interpolation


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Algorithm :: References :: Related

Back to top

Description


Generates a raster image by interpolating image values obtained from the specified pixel locations using the natural neighbor interpolation method. This function uses the NNGRIDR code developed by Dr. D.F. Watson at the University of Western Australia.
Back to top

Parameters


nnint(fili, filo, dbvs, dboc, dbow, extrap, fldnme)

Name Type Caption Length Value range
FILI * str Input file name 1 -    
FILO * str Output file name 1 -    
DBVS * List[int] Input vector segment 1 -    
DBOC * List[int] Output interpolated image 1 - 1  
DBOW List[int] Output window 0 - 4 Xoffset, Yoffset, Xsize, Ysize
EXTRAP str Extrapolate (YES|NO) 0 - 3 YES | NO
Default: YES
FLDNME str Field name for elevation 0 - 64 Default: ATTRIBUTE

* Required parameter
Back to top

Parameter descriptions

FILI

Specifies the name of the GDB-format file that contain the GDB layer information.

FILO

Specifies the name of the GDB-format raster file to receive the output interpolated images.

If FILI and FILO are both raster files, FILI can be equal to FILO.

DBVS

Specifies the input vector segment from which the attribute value or z-coordinate is used as the basis for interpolation.

The vector segment can specify an arbitrary number of structures.

DBOC

Specifies the output image channel to receive the interpolated results.

DBOW

Specifies the raster window (Xoffset, Yoffset, Xsize, Ysize) to be output. If this parameter is not specified, the entire channel is output by default.

Xoffset, Yoffset define the upper-left starting pixel coordinates of the window. Xsize is the number of pixels that define the window width. Ysize is the number of lines that define the window height. The specified offset + size must not exceed the size of the image.

EXTRAP

Specifies whether to extrapolate the output data.

Available options are:

FLDNME

Specifies the field name that contains the elevation values.

If this parameter is specified as ZCOORD, the actual z-coordinates of the vectors are used. Field names are not case-sensitive, and they do not need to be specified in complete form. If more than one match exists, the first name is used.

Supported values are:

The Field Name (FLDNME) parameter is required only for vector layers that contain 3-D points or contours. For 3-D lines, the z-coordinates are automatically used. For 2-D layers, the elevation values are not specified.

The same name applies to all contour and 3-D point segments specified in the input vectors (DBVS) parameter. The segments that do not satisfy this requirement can be converted to the required format using ZVALTRNS.

If a field name other than ZCOORD is specified but is not found, this function attempts to use the z-coordinates of each vertex or point; this may, however, lead to unexpected results.

Back to top

Details

NNINT uses the Natural Neighbor Interpolation method to read the gray-level values for an arbitrary number of pixel locations. The gray-level values are used to generate a raster image based on the interpolation obtained from the specified gray levels.

The gray-level values are read from either a GDB layer or a vector segment stored in the input file.

Speed

The order of complexity of NNINT is O(n^2) for n data. For a local area within a large data set, it is recommended that you restrict the output image size by specifying it using the DBOW parameter.

Back to top

Example

The following example reads XYZ data from the GDB layer, dem100.dat and writes the results to the raster file irvine.pix, on output channel 8.

from pci.nnint import nnint

fili	=	"dem100.dat;XYZ"	# input channel containing points
filo	=	"irvine.pix"
dbvs	=	[]	# input not from DBVS
dboc	=	[8]	# channel to receive results
dbow	=	[]	# process entire image
extrap	=	"YES"	# extrapolate
fldnme	=	""	# not required

nnint( fili, filo, dbvs, dboc, dbow, extrap, fldnme )
Back to top

Algorithm

NNINT implements the Natural Neighbor Interpolation method and the NNGRIDR code developed by Dr. D.F. Watson at the University of Western Australia.

The Natural Neighbor coordinate was invented by Professor Robin Sibson, [Sibson 1980]. It can have more than one reference point. It is measured by the ratio of the area associated with one of the reference points to the total area surrounded by all of the reference points. For more information, see the Reference section.

The data from the input channel can be corrected then added to the Natural Neighbor Interpolation algorithm, which finds the natural neighbors and performs the interpolation.

The data becomes a natural neighbor when it is located on the circumference of a circle. Natural neighbors of a data set are found by laying down the least number of the largest possible circles that completely cover the convex hull of data with no data present within the circle. This is achieved by constructing each circle with exactly three data points, which form a Delaunay triangle.

Any position (x) inside the triangle formed by the three data points (the Delaunay triangle vertices) is interpolated based on the weight or distance between x and each point. The relevant circle is also determined by the three points.

The interpolated value of a location is based on the influence from all of the circles that it intercepts. The interpolated value equals the sum of the product of the Natural Neighbor's coordinate and the gray level of each data point.

For example:

          ___
  f(x) =  \   Nx(i) * f(P(i))
          /__ 
           i
  
where:
Back to top

References

Sibson, R. "A vector identity for the Dirichlet tessellation", Math Proc. Cambridge Philos. Soc., no. 87 (1980): 151-155.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.