Nearest-neighbour (NN) interpolation

This tool can be used to interpolate a regular grid raster from an XYZ points dataset using a nearest-neighbour (NN) interpolation method. Notice that this interpolation method is particularly suited to situations where the surface contains numerous discontinuities, such as off-terrain objects, and when the point density is high, such as is frequently the case with LiDAR data sets. The user specifies the name of the input points file and the name of the output raster grid to be created. The input points file can either be a binary file containing X-coordinate, Y-coordinate, and Z-value triplets (in 64-bit double-precision floating-point format with an .xyz file extension) or an ASCII text file. If an ASCII text file is input, the user may specify which columns correspond to the X- and Y-coordinates and Z-values, i.e. it may be a table containing numerous columns. There is no need to specify the corresponding columns if a binary .xyz file is used because the format is assumed to contain XYZ triplets in regular sequence. Notice that if an ASCII text file is input, the program will automatically create and store a new binary .xyz points file, which can be used at a later date. Reading binary data from storage is many times faster for binary data than ASCII data, which is why the binary file is created and stored. The user must ensure that there is sufficient storage on the disc for the new binary file.

The user must also specify the search radius and the grid resolution of the output raster. Grid cells that have no points within the search radius assigned the NoData value in the output image. The output raster is of the float data type and continuous data scale.

Notice that LiDAR datasets contained within LAS files (.las file extension) can be interpolated using the complementary LiDAR NN interpolator, which provides a richer set of interpolation options including the ability to interpolate first or last returns only.

See Also:

Scripting:

The following is an example of a Python script using this tool:

wd = pluginHost.getWorkingDirectory()
# You may have multiple input files but they must
# be separated by semicolons in the string.
inputFiles = wd + "input1.shp" + ";" + wd + "input2.shp" + ";" + wd + "input3.shp"
attribute = "INCOME"
firstLineHeader = "false" # text input only
outputFile = wd + "output.dep"
gridRes = "10.0"
searchDist = "100.0"
args = [inputFiles, attribute, firstLineHeader, outputFile, gridRes, searchDist]
pluginHost.runPlugin("InterpolateNN", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
// You may have multiple input files but they must
// be separated by semicolons in the string.
def inputFiles = wd + "input1.txt" + ";" + wd + "input2.txt" + ";" + wd + "input3.txt"
def attribute = "not specified" // only for shapefile input
def firstLineHeader = "false" def outputFile = wd + "output.dep"
def gridRes = "10.0"
def searchDist = "100.0"
String[] args = [inputFiles, attribute, firstLineHeader, outputFile, gridRes, searchDist]
pluginHost.runPlugin("InterpolateNN", args, false)

Credits: