GDAL Nearest Neighbor Interpolation
Overview
Nearest neighbor interpolation is a deterministic, non-smoothing interpolation method that assigns values from the nearest sample point. For each location to be interpolated, the method finds only the known sample point that is closest in spatial distance and directly uses that point's value as the output result.
This method does not modify, smooth, or apply weighted estimation to the source data. It is essentially a direct copy of observed values. It does not create new values during interpolation, so it strictly preserves the value characteristics of the original sample points.
How It Works
For any location to be interpolated, , the interpolation result is taken directly from the nearest sample point, :
Where:
- : the distance between the interpolation location and the -th sample point.
- : the sample point closest to among all sample points.
Use Cases
- Categorical data interpolation: Suitable for land use types, vegetation cover classes, administrative division codes, and similar data. Because no intermediate values are created, interpolation results remain valid category codes.
- Original value preservation: Useful when no mathematical smoothing is desired and a coverage surface needs to be generated quickly.
- Fast raster gap filling: Fills small missing areas using the nearest cell value.
Parameters
| Parameter | Description | Notes |
|---|---|---|
| Input vector file | The vector dataset that contains spatial point features to interpolate. | Supports SHP, GeoJSON, and other formats. |
| Interpolation field | The numeric or categorical attribute column used for interpolation. | Supports integer or floating-point fields. |
| X-direction search radius | The semi-axis length of the elliptical search neighborhood in the X direction (radius1). | Limits the maximum spatial range used to find the nearest point. |
| Y-direction search radius | The semi-axis length of the elliptical search neighborhood in the Y direction (radius2). | Defines the search boundary together with radius1. |
| Rotation angle (Angle) | The counterclockwise rotation angle of the elliptical search neighborhood relative to the X axis. | Used for neighborhood searches with directional characteristics. |
| Output settings | Defines the spatial reference, extent, and cell size of the result raster. | See Common raster output. |
| Output file | Specifies the storage location and file name of the output raster data. | See Common raster output. |
Steps
- Start the tool: Open Raster Basic Tools > Interpolate to Raster, then double-click Nearest Neighbor Interpolation.
- Set the input: Select the vector point layer and specify the interpolation field.
- Configure the search neighborhood: Set the X/Y-direction search radius. If no sample point exists within the range, the location is output as NoData.
- Configure output properties: In Output settings, define the coordinate system, analysis extent, and cell size.
- Run the tool: Click Run.
Notes
- Blocky effect: Because the method directly copies the nearest point value, the generated surface often appears blocky or stepped and lacks continuity and smoothness.
- Spatial representativeness: When sample points are very sparse, one point value may control a large cell area, causing substantial generalization of spatial characteristics.
- Not suitable for continuously varying variables: For variables that change continuously in space, such as temperature or elevation, nearest neighbor interpolation often causes obvious abrupt changes. Use IDW or linear interpolation instead.
Nearest neighbor interpolation example